Showing posts with label rescue. Show all posts
Showing posts with label rescue. Show all posts

2012-12-30

Migrate /home in Ubuntu

Sadly Ubuntu does not have LVM enabled in the default install, as this whole issue would be solved with a simple pvmigrate and lvresize...

My /home (which is on a separate /dev/sda5 partition) is filling up.
The availability of Steam on Linux gave it the final blow: it's time to bring in another partition.
As I don't want to commit a whole partition to /home, I've mounted /dev/sdc2 as /space and I'm going to create a symlink to an home subdirectory.

First, boot Ubuntu in rescue mode and select root shell.

Mount all filesystems

#mount -a

note that mounted filesystem won't be visible with a df, but you should cat /proc/mounts to see them
Set proper permission to the new partition

#chown root:root /space
#chmod 755 /space

Then create the new home and copy the old one

#mkdir /space/home
#cp -a /home/* /space/home/

Mount / read/write as we'll need to modify the fstab

#mount / -o rw,remount
#vi /etc/fstab

Comment the old /home
Remove the old home mount point and create the new symlink

#umount /home
#rmdir /home
#ls -s /space/home /home

Reboot

2012-10-15

Mounting a disk image

Dumping a full disk is a quick way to perform a backup:

# dd if=/dev/sdb of=filename.dsk

But once you have such a dump, you can't directly mount it, you must use kpartx:

# kpartx -av filename.dsk
add map loop0p1 (252:0): 0 7830408 linear /dev/loop0 1144

You can see the partitions with fdisk

# fdisk -l /dev/loop0

Disk /dev/loop0: 4009 MB, 4009754624 bytes
128 heads, 22 sectors/track, 2781 cylinders, total 7831552 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc3072e18

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1   *        1144     7831551     3915204    b  W95 FAT32


Now you can mount the partitions that are inside the disk image.

# mount /dev/mapper/loop0p1 /mnt
# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/sda5             31G   12G   18G  41% /
udev                 3.9G  8.0K  3.9G   1% /dev
tmpfs                1.6G  960K  1.6G   1% /run
none                 5.0M     0  5.0M   0% /run/lock
none                 3.9G  200K  3.9G   1% /run/shm
/dev/sdb5             20G  1.4G   18G   8% /home
/dev/mapper/loop0p1  3.8G  1.1G  2.7G  29% /mnt


Once you've done, you can umount it with

# umount /mnt
# kpartx -dv filename.dsk
del devmap : loop0p1
loop deleted : /dev/loop0


Note:
Ubuntu doesn't have kpartx installed by default:

# sudo apt-get install kpartx


2012-01-19

grub rescue >


Panic! On my dual boot pc, a failed linux upgrade had wiped the linux boot partion.
The Windows partitions is still there, but unbootable: the boot process was struck at a grub error


error: no such partition.

grub rescue >

The MRB had to be rewritten but I had no Windows install CD ready at hand.
By chance, I had a GParted Live CD in the desk drawer.
I've booted it and luckily it had the ms-sys command on board: ms-sys just rewrites a Windows MBR on the HD.

# ms-sys -m /dev/hda

Reboot.
Windows was back up and running.