![]() |
WARNINGThis is a HOWTO. I written it as a reminder: after a few days, my NSLU2 print server were out of order, and in spite of an fsck on each partition of that bloody SDHC memory card and the re-creation of the swap space on it, unable to boot. Hopefully, I has another NSLU2, and a good disk plugged on. So, I could re-copy and adapt a new disk on that one, the plug the last more than one time, because of numerous mistakes due to my impatience. So, to avoid headaches from me and others, I wrote the few following lines. I cannot guarantee that you'll not break your system while follow them. I checked it twice (and more!), but it is your responsability to follow it or ADAPT IT TO FIT YOUR ACTUAL SYSTEM. It is wise to print a hardcopy, check and adapt all the operations before to begin, then follow and check step by step the operations you'll make. PurposeThis HOWTO describes the operations required to get a spare system disk for a Debian powered NSLU2 Summary
0. Conventions
If you prefer to use sudo for root commands, then insert sudo when a # sign appears. 1. Get the new diskIn order to have a backup for your system disk, you need a disk which global size is larger than the global size of the system partitions content you have to save. To determine the actual size occupied by your system data, simply connect via ssh to your Slug, then type: $ df -h Filesystem Size Used Avail Use% Mounted on /dev/sda2 471M 59M 389M 14% / tmpfs 15M 0 15M 0% /lib/init/rw udev 10M 56K 10M 1% /dev tmpfs 15M 0 15M 0% /dev/shm /dev/sda5 5.6G 507M 4.8G 10% /usr /dev/sda6 9.2G 458M 8.3G 6% /var /dev/sda7 1.9G 48M 1.7G 3% /var/log /dev/sda8 1.9G 35M 1.8G 2% /tmp /dev/sda9 9.2G 150M 8.6G 2% /home These are all data mounts on your system. You can safely ignore:
So, the minimum will be the sum of all other partitions, plus ~10%
Now, type: $ /sbin/fdisk -l /dev/sda Disk /dev/sda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 62 497983+ 82 Linux swap / Solaris /dev/sda2 63 124 498015 83 Linux /dev/sda3 125 9729 77152162+ 5 Extended /dev/sda5 125 854 5863693+ 83 Linux /dev/sda6 855 2071 9775521 83 Linux /dev/sda7 2072 2315 1959898+ 83 Linux /dev/sda8 2316 2559 1959898+ 83 Linux /dev/sda9 2560 3776 9775521 83 Linux You can see above a partition we didn't count:
# swapon -s Filename Type Size Used Priority /dev/sda1 partition 497972 46608 -1 Divide the size field by 1024 to obtain the actual swap size in Mbytes. eg:
Then round to the 1OO MBytes? upper (as you probably used a size multiple of 100MBytes). Add that size to the one you noted before. If you plan to split/merge the existing partitions to a new layout, do not forget that filesystem itself on each partition takes ~5% of the actual size of the partition Summaryneeded size = SUM( (df -h, except virtual filesystems),(SUM(swap partitions))) * 1,05. You can now visit your favourite reseller, then plug your brand new USB 2.0 disk. 2. Make the new partitions layout.There is only one rule: In order to boot, the swap partition and the Remember we have: Device Boot Start End Blocks Id System /dev/sda1 1 62 497983+ 82 Linux swap / Solaris /dev/sda2 63 124 498015 83 Linux That means, if the root partition above were not /dev/sda2, but the first logical partition, and the extended partition were /dev/sda3, you must create /dev/sdb1 as swap, then /dev/sdb3 as extended, then /dev/sdb5 as "/", Linux. Below, we now create the partitions in respect of the existing table of sda1: remain$ /sbin/fdisk -l /dev/sda Disk /dev/sda: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 62 497983+ 82 Linux swap / Solaris /dev/sda2 63 124 498015 83 Linux /dev/sda3 125 9729 77152162+ 5 Extended /dev/sda5 125 854 5863693+ 83 Linux /dev/sda6 855 2071 9775521 83 Linux /dev/sda7 2072 2315 1959898+ 83 Linux /dev/sda8 2316 2559 1959898+ 83 Linux /dev/sda9 2560 3776 9775521 83 Linux operations# fdisk /dev/sdb The number of cylinders for this disk is set to 9729. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p => nothing, this is OK Command (m for help): n Command action e extended (1-4) p primary partition (1-4) p''return'' partition number(1-4): 1 First cylinder (1-9729, default 1):''return'' Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729): +500M Command (m for help):p Disk /dev/sdb: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 62 497983+ 82 Linux Command (m for help): t Partition 1 selected Hex code (type L to list codes): 82 '''=> Linux swap''' Changed system type of partition 1 to 82 (Linux swap / Solaris) Command (m for help):n''return'' partition number(2-4):2''return'' First cylinder (63-9729, default 63):''return'' Last cylinder or +size or +sizeM or +sizeK (63-9729, default 9729): +2000M''return'' Command (m for help):p''return'' Disk /dev/sdb: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 1 62 497983+ 82 Linux swap / Solaris /dev/sda2 63 124 498015 83 Linux Command (m for help):n''return'' Command action e extended (1-4) p primary partition (1-4) e''return'' partition number(1-4): 3 First cylinder (125-9729, default 125):''return'' Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729):''return'' Command (m for help): n Command action l logical (5 or over) p primary partition (1-4) l First cylinder (125-9729, default 125):''return'' Last cylinder or +size or +sizeM or +sizeK (1-9729, default 9729):+6000M''return'' Command (m for help): p Disk /dev/sdb: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 62 497983+ 82 Linux swap / Solaris /dev/sdb2 63 124 498015 83 Linux /dev/sdb3 125 9729 77152162+ 5 Extended /dev/sdb5 125 854 5863693+ 83 Linux Command (m for help):n you continue the n (new) operations with l (logical) to the end of your partition list), then verify a last time the layout, and write (w), or quit in emergency (q): Command (m for help): p Disk /dev/sdb: 80.0 GB, 80026361856 bytes 255 heads, 63 sectors/track, 9729 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 62 497983+ 82 Linux swap / Solaris /dev/sdb2 63 124 498015 83 Linux /dev/sdb3 125 9729 77152162+ 5 Extended /dev/sdb5 125 854 5863693+ 83 Linux /dev/sdb6 855 2071 9775521 83 Linux /dev/sdb7 2072 2315 1959898+ 83 Linux /dev/sdb8 2316 2559 1959898+ 83 Linux /dev/sdb9 2560 3776 9775521 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. SummaryYou have prepared -- copied or modified -- your new partition plan You were attentive to create the main root and swap partitions number in respect of the former partition layout, included extended partition if relevant Note: there is no problem to not create the primary partitions in order on the disk (/dev/sdb4 can be created at cylinder 1, etc). Prepare the image directory, copy the former partitions content to the targetsWe assumes here the new drive is Here we create the directories we will mount the new partitions on: foobar@nslu2:~$ mkdir newlayout && cd newlayout foobar@nslu2:~/newlayout$ for dir in slash sl_user sl_var sl_var_log sl_home > do > mkdir $dir > done Now, we format the new partitions tom@littleblue:~/newlayout$ su Password: littleblue:/home/tom/newlayout# for dev in /dev/sdb{2,5,6,7,8,9} do mkfs.ext3 $dev done [.................................................] littleblue:/home/tom/newlayout# mkswap /dev/sdb1 [.................................................] Now, we check and mount the new partitions on each relevant directory littleblue:/home/tom/newlayout# fsck.ext3 /dev/sdb2 && mount /dev/sdb2 slash littleblue:/home/tom/newlayout# fsck.ext3 /dev/sdb5 && mount /dev/sdb5 sl_usr littleblue:/home/tom/newlayout# fsck.ext3 /dev/sdb6 && mount /dev/sdb6 sl_var littleblue:/home/tom/newlayout# fsck.ext3 /dev/sdb7 && mount /dev/sdb7 sl_var_log littleblue:/home/tom/newlayout# fsck.ext3 /dev/sdb9 && mount /dev/sdb2 sl_home Now, we copy the content of the littleblue:/home/tom/newlayout# cd slash littleblue:/home/tom/newlayout/slash# tar cf - -C / --one-file-system . | tar xf - Note: if you use sudo, use it on the both sides of the pipe Note: we use a tar option ( Note: you can make the tar command verbose by typing "cvf" instead of "cf" after the pipe, but you will certainly miss the warnings Note: if your plan is to change de layout, by moving eg /usr on another partition,
use: Now, we copy the content of each partition root directory to the relevant target directory (a mounted /dev/sdbx partition) littleblue:/home/tom/newlayout/slash# cd ../sl_usr littleblue:/home/tom/newlayout/sl_usr# tar cf - -C /usr . | tar xf - littleblue:/home/tom/newlayout/sl_usr# cd ../sl_var littleblue:/home/tom/newlayout/sl_var# tar cf - -C /var --one-file-system . | tar xf - littleblue:/home/tom/newlayout/sl_var# cd ../sl_var_log littleblue:/home/tom/newlayout/sl_var_log# tar cf - -C /var_log . | tar xf - littleblue:/home/tom/newlayout/sl_var_log# cd ../sl_home littleblue:/home/tom/newlayout/sl_home# tar cf - -C /home . | tar xf - Note: we can safely ignore /tmp beside Note: we use a tar option ( Note: if your plan is to change de layout, by moving eg /var/www on another partition,
use: SummaryWe
Create the devicesYou remember that while copying the former / (aka This option allowed us to not soil the root filesystem with unwanted stuff, and insulate the other filesystems contents from the extracted archive. This has (hopefully) a side effect: the Or, we need to populate the /dev directory with a set of devices (pseudo-files to access the hardware, which point to the kernel in a way you'll find elsewhere). So, here are the operations:
littleblue:/anywhere# # cd /home/tom/newlayout/slash littleblue:/home/tom/newlayout/slash# cd dev littleblue:/home/tom/newlayout/slash/dev# pwd /home/tom/newlayout/slash/dev Note: be carefull to be in the slash/dev directory as typed above, as it is really an hassle to revert the mess you done otherwise. You have been warned
littleblue:/home/tom/newlayout/slash/dev# cp -p /dev/MAKEDEV . littleblue:/home/tom/newlayout/slash/dev# pwd /home/tom/newlayout/slash/dev littleblue:/home/tom/newlayout/slash/dev# ./MAKEDEV generic You can quietly prepare and drink a cup of tea (about 3 beers long :) ) SummaryWe populated the target Create the missing directoriesRemember: in case you changed the filesystem layout in the target disk, you used the
This has the side effect that the mountpoints directories misses in their parent target filesystem. For example, we have splitted So, it is time to:
Assuming /var has been already a partition, and the new disk target for the future Here are the commands:
littleblue:/anywhere# # cd /home/tom/newlayout/slash littleblue:/home/tom/newlayout/slash# cd etc littleblue:/home/tom/newlayout/slash/etc# pwd /home/tom/newlayout/slash/etc littleblue:/home/tom/newlayout/slash/etc# vi fstab ******* vi screenshot ********************************************************** # /etc/fstab: static file system information. # # <file system> <mount point> <type> <options> <dump> <pass> proc /proc proc defaults 0 0 /dev/sda1 none swap sw 0 0 /dev/sda2 / ext3 defaults,errors=remount-ro 0 1 /dev/sda5 /usr ext3 defaults 0 2 /dev/sda6 /var ext3 defaults 0 2 /dev/sda7 /var/log ext3 defaults 0 0 /dev/sda8 /tmp ext3 defaults 0 2 /dev/sda9 /home ext3 defaults,acl 0 2 ~ ~ ~ "/etc/fstab" 11L, 658C 1,1 All ******************************************************************************** [escape]G [escape]o ******************************************************************************** ................. /dev/sda8 /tmp ext3 defaults 0 2 /dev/sda9 /home ext3 defaults,acl 0 2 [cursor] ******************************************************************************** ................. /dev/sda8 /tmp ext3 defaults 0 2 /dev/sda9 /home ext3 defaults,acl 0 2 /dev/sda10 /var/www/ ext3 defaults 0 2[cursor] ********************************************************************************* [escape]:wq littleblue:/home/tom/newlayout/slash/etc#
littleblue:/home/tom/newlayout/slash/etc# cd home/tom/newlayout/sl_var littleblue:/home/tom/newlayout/sl_var# pwd home/tom/newlayout/sl_var littleblue:/home/tom/newlayout/sl_var# mkdir www littleblue:/home/tom/newlayout/sl_var# SummaryWe created here the missing directory mountpoints, and added the relevant entries
in the target Verifying that everything is OKThe checklist:
And:
Reread the HOWTO from the beginning to this point. Point the operations you made. Umounting the new disk filesystemslittleblue:/anywhere# cd in case you are connected via su, quit the root session, then check the standard user is not in one of the new target directories
(simply type litlittleblue:/anywhere/but/targets# umount /dev/sdb* You can safely ignore the warnings about not mounted filesystems. SummaryWu umounted the new filesystems Now you can switch off your NSLU2litlittleblue:/anywhere# poweroff Plug your new disk
Push the start button, check the leds
Try to connect to your NSLU2 via SSH. If it doesn't succeed, push the power button, then unplug power chord while you'll get the cartepillar leds blinking. Swap the disks, and try to guess what is wrong. If you got the redystatus led heartbeat, you most probably missed the fstab entry for /usr. Check for the processes ( You can now poweroff your NSLU2, then swap the disks and keep your spare one in a safe place. Or You can keep the new disk with it's updated layout. So have a beer (or, safer, a tea). Page last modified on July 20, 2008, at 03:01 PM
|