Tuesday, June 21, 2011

Resizing Disk Images in Linux

To resize the disk image in Linux, do

# sudo fsck.ext4 -f DISK_IMAGE_FILE
# sudo resize2fs DISK_IMAGE_FILE

This is very helpful specially if you are having an instance in the cloud and wanted to resize an image.

Mounting an EBS in Eucalyptus

First, do

# fdisk -l

to list the device available. You can identify what's the current device the Eucalyptus have avail for the current block storage given.

Now, to mount this, do

# mkfs.ext4 /dev/sda

where my current filing system is ext4 and the availed virtual device is /dev/sda. Then afterwards, you can do

# mount -t ext4 /dev/sda /path/to/mounted/directory

Hope this helps.

Eucalyptus - Save current Instance as backup with the power of "dd" command

The current setup for this is that, I have this current instance in Eucalyptus and was already customized while its being in the cloud. This means like, installing packages and added extra configurations to some packages. While its time wasting if to go back and install those packages, doing a dd (disk dump) tool is very helpful.

Below is the command I issued,

#> dd if=/dev/vda1 of=jenkins.img conv=noerror,sync 

I use the conv=noerror,sync which the sync to sync every input block and also its meta data. I've tried w/o that option and it didn't work. 

After I run this into the cloud, I can ssh and I see the state before dd finished, it was there. It's really great!

Hope this helps!

Delete a file with a leading "dash" or (-) in Linux

To delete a file with a leading dash, for example,

# ls -al
total 36195068
drwxr-xr-x  3 toor toor        4096 2011-06-15 16:46 .
drwxrwxrwx 12 toor toor        4096 2011-06-21 14:11 ..
-rw-r--r--  1 toor toor        6887 2011-06-10 13:01 -C


# unlink -- -C

Hope this helps