Partitions
Home Up Partitions Replacing dropbear

 

Partitions

On a fileserver it's often a good idea to arrange for the shared files to be on a different partition from the main system. It makes updating easier as the system partition can be reformatted without damaging user data and it makes recovery easier as only the data partition needs to be searched.

When installing Ubuntu Linux on my PC I arrange for the /home folder to be on a separate partition. I'm going to do the same here. 

First task: creating the partitions.

For this I strongly recommend booting your PC with a Gparted LiveCD and connecting your server's drive directly to your PC. This way it is easy to shrink the existing partition and create a new one. You could probably tell the slug to boot from flash ("turnup flash") and partition from the SlugOS command line but that's currently beyond my knowledge.

Second task: preparing the partition.

I'm going to add a soft link to /root as there is one in the existing /home directory and I want the new home to have the same link in case programs and scripts expect it to be there.

Incidentally if you already have directories in /home now is a good time to move them.

root@zebidee:/# cd media/sda2
root@zebidee:/media/sda2# ls
lost+found
root@zebidee:/media/sda2# ln -s /root root
root@zebidee:/media/sda2# ls -l
drwx------ 2 root root 16384 Dec 28 16:35 lost+found
lrwxrwxrwx 1 root root 5 Dec 28 16:53 root -> /root
root@zebidee:/media/sda2# cd /
root@zebidee:/#

Remounting

Not sure if this is strictly necessary but just to make sure I'll check it mounts:

root@zebidee:/# mount
rootfs on / type rootfs (rw)
/dev/root on /initrd type jffs2 (ro)
/dev/sda1 on / type ext3 (rw,noatime,data=ordered)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
/dev/sda1 on /dev/.static/dev type ext3 (rw,noatime,data=ordered)
tmpfs on /dev type tmpfs (rw)
/dev/sda2 on /media/sda2 type ext3 (rw,sync,data=ordered)
tmpfs on /media/ram type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
devpts on /dev/pts type devpts (rw)
root@zebidee:/# 

Try to mount /dev/sda2 on /home:

root@zebidee:/# mount /dev/sda2 /home
root@zebidee:

Check it:

root@zebidee:/# mount
rootfs on / type rootfs (rw)
/dev/root on /initrd type jffs2 (ro)
/dev/sda1 on / type ext3 (rw,noatime,data=ordered)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
/dev/sda1 on /dev/.static/dev type ext3 (rw,noatime,data=ordered)
tmpfs on /dev type tmpfs (rw)
/dev/sda2 on /media/sda2 type ext3 (rw,sync,data=ordered)
tmpfs on /media/ram type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
devpts on /dev/pts type devpts (rw)
/dev/sda2 on /home type ext3 (rw,sync,data=ordered)
root@zebidee:/# 

If you check the /home directory it will now show a lost+found directory

Making it permanent

The mount points are stored in a text file /etc/fstab

This is what it contained:

/dev/sda1 / ext3 noatime 1 1
proc /proc proc defaults 0 0
tmpfs /media/ram tmpfs defaults 0 0
usbfs /proc/bus/usb usbfs defaults 0 0

Note: noatime is an option that's selected when you use a memory stick. It tells the filesystem to update the date stamp on files less often than it normally would, cutting down on the number of write operations.

I'm going to edit it using vi 

root@zebidee:/# vi /etc/fstab

to make it read:

/dev/sda1 / ext3 noatime 1 1
/dev/sda2 /home ext3 noatime 1 1
proc /proc proc defaults 0 0
tmpfs /media/ram tmpfs defaults 0 0
usbfs /proc/bus/usb usbfs defaults 0 0

You can also permanently make a partition into a swap partition. To turn a partition into swap do the following:

  1. Create an entry for it in fstab. Mount point is "swap" and fs is "swap".
  2. unmount it using umount
  3. convert it using the utility "mkswap"
  4. activate it using "swapon -a"

It's not enough to create the swap partition on a PC. I wasted a lot of time until I realised that the swap formats are incompatible. Gparted created a small-endian swapfile and Openslug requires big-endian swapfile. This is about the only instance I've seen where disk formats weren't compatible.

Checking it worked:

I reboot the slug: 

root@zebidee:/# reboot

Broadcast message from root (pts/0) (Thu Dec 28 16:57:05 2006):

The system is going down for reboot NOW!

After logging in again I run mount to check it:

root@zebidee:~# mount
rootfs on / type rootfs (rw)
/dev/root on /initrd type jffs2 (ro)
/dev/sda1 on / type ext3 (rw,noatime,data=ordered)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
/dev/sda1 on /dev/.static/dev type ext3 (rw,noatime,data=ordered)
tmpfs on /dev type tmpfs (rw)
/dev/sda2 on /home type ext3 (rw,noatime,data=ordered)
tmpfs on /media/ram type tmpfs (rw)
usbfs on /proc/bus/usb type usbfs (rw)
devpts on /dev/pts type devpts (rw)
root@zebidee:~# 

Success.


Home Up Partitions Replacing dropbear