Pages: << 1 2 3 4 5 6 7 8 9 10 >>

07/03/09

Permalink 06:15:49 pm, by richard Email , 92 words   English (GB)
Categories: Ubuntu Linux, OS and Systems Administration, Filing Systems

HOWTO:Mount an ISO

This is so easy, the second time 7|


You will need somewhere to mount the ISO. If you are expecting to do this more than once then create a specific ISO directory.

sudo mkdir -p /media/iso

Now you can mount the iso,

sudo mount -o loop /path/to/you.iso /media/iso

To access the iso image simply cd or access /media/iso which is now the root of your image.


When you are all done you can umount the image with

sudo umount /media/iso

30/12/08

HOWTO: Use parted to add and manipulate disk partitions

So you need to make some changes to the partitions on a hard disk whether it is adding new partitions, deleting partitions, resizing them or simply making a clone of a disk. You can use parted. fdisk and sfdisk both state that:

fdisk doesn't understand GUID Partition Table (GPT) and it is not designed for large partitions.

For this reason I use parted in place of fdisk. It is very straight forward to use but does need some thought before diving in. Changes are put into place immediately and there is no undo option. When using parted or any other tool that manipulates the partition tables of your hard disk, make sure you have a backup of your data and that it can be restored! Better still play around with a virtual machine first, while you are learning.

Pages: 1 · 2

28/12/08

Hints and Tips for testing and trying things out.

These are a bunch of things I have picked up over the years and now do routinely. they have each saved me from losing real data or stopped me trashing my system and making it non functional.

1. Take regular backups and better still automate it so you don't have to remember to do it or find the time to do it. I use BackupPC for this task

Having made the effort to take regular backups make sure that you can restore from your backups. Yes and I do mean actually restore the data.

Many years ago I saw this happen. The company concerned took regular nightly backups on their Wang system to tape. Taking the tapes off site for long term storage. One day they had a hard disk crash. The old style head crash when the head literally crashed into the platter, Scoring and removing the recording medium.
They didn't panic they thought they had good backups from last night that they could just restore to a new hard disk platter. Any way the new hard disk platter arrived and was formatted. The first tape of five was inserted into the drive and the restore began, when the tape got to the end they did not see a message that said "Insert second tape" they got a fatal error saying "End of tape reached before end of file". On contacting Wang support they were told "Oh this is a known bug. It a file spans over two tapes you cannot restore the backup past that tape!" They lost most of their data as it could not be restored. They went bust shortly after as they were an Accountancy firm who had lost their clients financial records!

Pages: 1 · 2

27/12/08

HOWTO: Create a new RAID 1 (mirror)

You have two devices of approximately same size and want to mirror the data on one of them to the other to make your system more secure.

sudo fdisk /dev/sdb
The number of cylinders for this disk is set to 30401. 
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):

Use the p command to see the current partitions on the drive or just to make sure you have the right one :)

Command (m for help): p 
Disk /dev/sdb: 250.0 GB, 250059350016 bytes 
255 heads, 63 sectors/track, 30401 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
Disk identifier: 0x00045339 
 
   Device Boot      Start         End      Blocks   Id  System 
 

Add a new partition making sure the same size will fit on both disks if they are not exactly the same.

Command (m for help): n 
Command action 
   e   extended 
   p   primary partition (1-4) 

Partition number (1-4): 1 
First cylinder (1-30401, default 1):  
Using default value 1 
Last cylinder or +size or +sizeM or +sizeK (1-30401, default 30401):  
Using default value 30401 

Lastly set the dick ID type to Linux RAID. This is what it would be set to if you have created the RAID 1 array while installing Ubuntu. I'm not going to argue with the guys that produce this great Linux distribution. :)

Command (m for help): t 
Selected partition 1 
Hex code (type L to list codes): fd 
Changed system type of partition 1 to fd (Linux RAID autodetect) 

Just one more check that all is as expected before writing the new values to the disk.

Command (m for help): p 
 
Disk /dev/sdb: 250.0 GB, 250059350016 bytes 
255 heads, 63 sectors/track, 30401 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
Disk identifier: 0x00045339 
 
   Device Boot      Start         End      Blocks   Id  System 
/dev/sdb1               1       30401   244196001   fd  Linux RAID autodetect 
 

This looks good to me so write away!

Command (m for help): w 
The partition table has been altered! 
 
Calling ioctl() to re-read partition table. 
Syncing disks. 

Do the same again for he second disk and we will be ready to create the new mirrored disk array.

sudo mdadm --create --verbose /dev/md1 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: size set to 244195904K 
mdadm: array /dev/md1 started. 
Note: I used md1 as the device name as I already used md0 for the raid 5 array. 
 

You can now watch the array sync itself over the two disks.

watch -n 7 cat /proc/mdstat  
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]  
md1 : active raid1 sdc1[1] sdb1[0] 
      244195904 blocks [2/2] [UU] 
      [>....................]  resync =  1.7% (4328640/244195904) finish=48.5min speed=82380K/sec 
 
unused devices: <none> 
 

You will of course need to format it, I use reiserfs so this is done with the following command. I like to label my disks as I think its make life a little simpler.

sudo mkreiserfs /dev/md1 --label=mirror_root
Guessing about desired format.. Kernel 2.6.24-22-generic is running. 
Format 3.6 with standard journal 
Count of blocks on the device: 61048976 
Number of blocks consumed by mkreiserfs formatting process: 10075 
Blocksize: 4096 
Hash function used to sort names: "r5" 
Journal Size 8193 blocks (first block 18) 
Journal Max transaction length 1024 
inode generation number: 0 
UUID: 1ab2c3d4-51b6-4471-b356-906cb9281293 
LABEL: mirror_root 
ATTENTION: YOU SHOULD REBOOT AFTER FDISK! 
        ALL DATA WILL BE LOST ON '/dev/md1'! 
Continue (y/n):y 
Initializing journal - 0%....20%....40%....60%....80%....100% 
Syncing..ok 
 
Tell your friends to use a kernel based on 2.4.18 or later, and especially not a 
kernel based on 2.4.9, when you use reiserFS. Have fun. 
 
ReiserFS is successfully created on /dev/md1. 

You can now mount the drive from the command line using

sudo mkdir /mnt/mirror 
sudo mount /dev/md1 /mnt/mirror 

or from within the fstab file with any ONE of the following. The UUID can be found by looking at the message given out from the command above when you put reiserfs on the array.

LABEL=mirror_root   /mnt/mirror    reiserfs   relatime   0       2 
/dev/md1            /mnt/mirror    reiserfs   relatime   0       2 
UUID=1ab2c3d4-51b6-4471-b356-906cb9281293 /mnt/mirror    reiserfs   relatime   0       2

The same method can be used to create RAID5 or RAID0 arrays. take a look at he RAID Setup pages here.

Finally you will need to update mdadm.conf with the new drive adding it to the existing list. Too find out all the UUIDs on the system you can use

sudo blkid
/dev/sda1: UUID="a0b4a885-6d24-48c8-b7fc-0000395781f9" TYPE="reiserfs"  
/dev/sdb1: UUID=1ab2c3d4-51b6-4471-b356-906cb9281293"  TYPE="linux_raid_member"  
/dev/sdc1: UUID="89c286e1-79cc-bbfa-d62d-508b2fbf3d7b" TYPE="linux_raid_member"

Edit /etc/mdadm/mdadm.conf and add the new drive to the ARRAY that of disk you have added the new drive to. Do not just copy my UUIDs they will not be the same as yours :DD

sudo nano /etc/mdadm/mdadm.conf
ARRAY /dev/md0 uuid=1ab2c3d4-51b6-4471-b356-906cb9281293" uuid=" ...

Now you need to rebuild the RAM disk image initrd.

sudo update-initramfs -c -k `uname -r`

Take a look at the man pages for mdadm.conf and update-initramfs.


22/12/08

HOWTO Expand a RAID 5 by replacing the disk with lager ones.

You can increase the size of your RAID 5 disk array by swapping out each disk in turn with a larger disk. This takes time, a lot of time if you have many disks in your array.

Make a full backup of your data. NOW!!
It is also very important to note that during the process your data is at risk until the resync process has finished. You did complete a full backup didn't you!

The following will need to be repeated for each drive you have in your disk array. The steps can all be done on a running and mounted system if you use reiserfs.


Select the drive you are going to replace and run the following commands. These will firstly mark the drive as faulty so it is no longer used. The second will remove it from the array. You have to do this as you cannot simply remove a good disk from a RAID array.

sudo mdadm -f /dev/md0 /dev/sdd1
sudo mdadm -r /dev/md0 /dev/sdd1

I like to run the following in a separate window. The command displays and re-displays the contents of /proc/mdstat every 7 seconds and shows you the status.

watch -n7 cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]  md0 : active raid5 sdd1[3] sdb1[0] sdc1[1]
      10474112 blocks level 5, 64k chunk, algorithm 2 [3/2] [UU_]
      [=================>...]  recovery = 86.3% (4522932/5237056) finish=0.5min speed=22697K/sec
 
unused devices: <none>

You can now turn off your machine and swap out the old hard drive, adding the new larger one in its place. This drive needs to be partitioned before being added to the array. You must make the partition the full size of the disk or the size you want to use in the new RAID array. For example if the old drive was 250Mb and you are swapping in 1Gb drives you make the partition 1Gb not 250Mb.
You also need to set the partition type or ID to 0xDA - Non-fs data or 0xFD, Linux raid autodetect. I use 0xFD as that is what Ubuntu Linux uses if you install from scratch using RAID.

sudo fdisk /dev/sdd

To get a list of commands that fdisk accepts type 'm', just like the prompt says :)

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the DOS compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
 
Command (m for help):

First check it is the right disk with 'p' print the partition table. There should be nothing displayed under the headings , if this was a brand new disk.

n add a new partition to add create the new partition I use a primary partition and set it to number 1. Then accept the defaults for the beginning and ending cylinder, to use the whole disk.

t change a partition's system id to set the id to '0xFD' you type just fd


and finally one last check all is well I print out what will be written with 'p' again.

Command (m for help): p
 
Disk /dev/sdd: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x94de950b
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         652     5237158+  fd  Linux RAID autodetect

Now we can add the new disk to the array with the following:

sudo mdadm --add /dev/md0 /dev/sdd1

You will see that after a few seconds your hard disks burst into life and stay active. The RAID array is being resynced and can take a few minutes to many hours. Time for a coffee :) Running the cat /proc/mdstat with watch at this point you will see the process run through until it is finished. Do not interrupt the process or it will start all over again. You can use your system while this is happening.

Repeat the above steps for all drives in your array before going on to the steps below.
 

So you have now replaced all your disks with larger drives. You can now grow the RAID array

sudo mdadm --grow /dev/md0 --size=max

The array now represents one disk using all of the new available space. If you check the disk usage with the 'df' command nothings has changed! What's up with this?


One last step you must resize the file system on the partition. I use reiserfs so this can be done on the fly while the system is still mounted.

sudo resize_reiserfs -f /dev/md0

Now when you check the disk usage you will see the correct size of the RAID array.


All done!

Pages: 1 · 2

<< 1 2 3 4 5 6 7 8 9 10 >>