Monday, November 20, 2006

Samba on Centos Anonymous Read Only

I wanted to start with an empty config. So log in as root and do the following:

cd /etc/samba
mv smb.conf smb.conf.bak
vi smb.conf

Place the following in smb.

[global]
workgroup = Home_lan
netbios name = Centos
security = share

[public]
comment = public
path = /server/public
force user = dj
force group = home
read only = Yes
guest ok = Yes

The directory public is owned by dj & the group is home. Now test the config file.

testparm

If everything checks out ok then start samba.

service smb start

I did give the user dj a samba password by doing the following but I doubt you'll need it. When I connected w/ a windows box it didn't ask for a logon.

smbpasswd -a dj

Credits
http://us4.samba.org/samba/docs/man/Samba-HOWTO-Collection/FastStart.html

Tuesday, November 14, 2006

Migrating from Ubuntu to Centos

First blog, it's gona be kinda ugly.

My server orginally was running Ubuntu Breezy Badger. I liked ubuntu but too many problems started happening. When I added a new harddrive I figured it was time to update to dapper or maybe even edgy. Those were even worse then breezy. Hence the switch to centos. Might as well put that RHCT to use.

A little about the partitioning scheme the server is using for this migration. Theres two harddrives each 250gb.

/dev/sda5 is the new LVM partition. The goal is to move the data from /dev/hda6 onto the new lvm parition. Then erase the old harddive and extend the lvm across both drives. Plenty of room for backups.

Problem right off the back. Centos doesn't support xfs. hda6 is formated as xfs. Dapper drake cd worked fine. Boot off it like a live cd. Heres the commands I did.

mkdir /server
mkdir /server-old
lvscan

#lvscan showed the output I needed to mount it. See lvm is logical volume management. I don't have the notes I used to create it but this is how it works.
pvcreate a physical partition like /dev/hda6. Then vgcreate and add it to a volume group. From there you use lvcreate to create a logical volume and format it. This case it would've been mkfs.ext3 /dev/server/server
mount /dev/server/server /server
mount /dev/hda6 /server-old

#Check to make sure I have enough space.
df -h
#df shows that /dev/hda6 is using about 182G so I needed to extend my logical volume cause it was only a 100G

lvextend -L +100G /dev/server/server
#Then extend the filesystem
#Dapper doesn't have the e2fsadm so reboot
reboot
e2fsck -f /dev/server/server
resize2fs /dev/server/server 200G
mount /dev/server/server /server
#Check space once more
df -h
#Back into Dapper
reboot

#switch to a virtual console and then to runlevel 1 so the x server isn't running. Start screen incase this thing dies for some odd reason
ctrl+alt+f1
sudo -i
init 1
screen
mkdir /server; mount /dev/server/server /server
mkdir /old; mount /dev/hda6 /old
#Sync the old to the new. a preserves a lot of stuff like permissions it's called archive and the v is verbose. It'll least each file being copied.
rsync -av /old /server

I let that run overnite and to be safe I ran the command again this morning. There were no changes I rebooted to get back into Centos.

#Now to erase the partition table for the old harddrive and create one big one. Don't forget to change the id to 8e for Linux LVM.
fdisk /dev/hda
#Partprobe to update the kernel of partition changes
partprobe
#Now set that partition up and extend the lvm onto it.
pvcreate /dev/hda1
vgextend server /dev/hda1
vgdisplay
lvextend -L +54G /dev/server/server
#I left 200G if I wanted to create a new lv. I can always extend this one if it's needs the space. It's easier to extend then reduce lvms.
e2fsck -f /dev/server/server
resize2fs /dev/server/server 254G

#Credits
Couldn't remember how to extend a ext3 filesystem but found it here
http://wiki.centos.org/TipsAndTricks/ResizeExt3