Sunday, January 16, 2011

detect and mount disk in linux VM

[root@server ~]# cat /proc/scsi/scsi


Attached devices:

Host: scsi0 Channel: 00 Id: 00 Lun: 00

Vendor: VMware Model: Virtual disk Rev: 1.0

Type: Direct-Access ANSI SCSI revision: 02

[root@server ~]# echo "scsi add-single-device 0 0 1 0" > /proc/scsi/scsi

[root@server ~]# tail -3 /var/log/messages

Jan 15 12:45:48 server kernel: sdb: unknown partition table

Jan 15 12:45:48 server kernel: sd 0:0:1:0: Attached scsi disk sdb

Jan 15 12:45:48 server kernel: sd 0:0:1:0: Attached scsi generic sg1 type 0

[root@server ~]# cd /dev/

[root@server dev]# fdisk -l



Disk /dev/sda: 38.6 GB, 38654705664 bytes

255 heads, 63 sectors/track, 4699 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes



Device Boot Start End Blocks Id System

/dev/sda1 * 1 17 131072+ 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 17 4700 37617568 8e Linux LVM



Disk /dev/sdb: 59.0 GB, 59055800320 bytes

255 heads, 63 sectors/track, 7179 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes



Disk /dev/sdb doesn't contain a valid partition table

[root@server dev]# ./MAKEDEV sdb

[root@server dev]# fdisk -l



Disk /dev/sda: 38.6 GB, 38654705664 bytes

255 heads, 63 sectors/track, 4699 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes



Device Boot Start End Blocks Id System

/dev/sda1 * 1 17 131072+ 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 17 4700 37617568 8e Linux LVM



Disk /dev/sdb: 59.0 GB, 59055800320 bytes

255 heads, 63 sectors/track, 7179 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes



Disk /dev/sdb doesn't contain a valid partition table

[root@server dev]# pvcreate /dev/sdb

Physical volume "/dev/sdb" successfully created

[root@server dev]# vgcreate VolGroup01 /dev/sdb

Volume group "VolGroup01" successfully created

[root@server dev]# vgdisplay

--- Volume group ---

VG Name VolGroup01

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 1

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 0

Open LV 0

Max PV 0

Cur PV 1

Act PV 1

VG Size 55.00 GB

PE Size 4.00 MB

Total PE 14079

Alloc PE / Size 0 / 0

Free PE / Size 14079 / 55.00 GB

VG UUID 0CIkNO-1gus-k7o3-fFPd-6lCW-UdJD-y9jpro



--- Volume group ---

VG Name VolGroup00

System ID

Format lvm2

Metadata Areas 1

Metadata Sequence No 8

VG Access read/write

VG Status resizable

MAX LV 0

Cur LV 7

Open LV 7

Max PV 0

Cur PV 1

Act PV 1

VG Size 35.84 GB

PE Size 32.00 MB

Total PE 1147

Alloc PE / Size 1147 / 35.84 GB

Free PE / Size 0 / 0

VG UUID reWZnW-Pgco-u2sT-cI3v-yDUS-Ku3H-yDhuYk



[root@server dev]# vgdisplay VolGroup01
grep pe

Open LV 0

[root@server dev]# vgdisplay VolGroup01
grep PE

PE Size 4.00 MB

Total PE 14079

Alloc PE / Size 0 / 0

Free PE / Size 14079 / 55.00 GB

[root@server dev]# lvcreate -l 14079 -n LogVol00 VolGroup01

Logical volume "LogVol00" created

[root@server dev]# lvdisplay /dev/VolGroup01/LogVol00

--- Logical volume ---

LV Name /dev/VolGroup01/LogVol00

VG Name VolGroup01

LV UUID 2BWVtT-mBnf-LXNC-UBtk-r4em-RQ4u-YdcudY

LV Write Access read/write

LV Status available

# open 0

LV Size 55.00 GB

Current LE 14079

Segments 1

Allocation inherit

Read ahead sectors auto

- currently set to 256

Block device 253:7



[root@server dev]# mkfs.ext3 -m0 /dev/VolGroup01/LogVol00 -L /local

mke2fs 1.39 (29-May-2006)

Filesystem label=/local

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

7208960 inodes, 14416896 blocks

0 blocks (0.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

440 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

4096000, 7962624, 11239424



Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done



This filesystem will be automatically checked every 35 mounts or

180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@server dev]# vi /etc/fstab

[root@server dev]# vi /etc/fstab

[root@server dev]# mkdir /scratch

[root@server dev]# umount /local

[root@server dev]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

992M 448M 493M 48% /

/dev/mapper/VolGroup00-LogVol05

2.0G 69M 1.8G 4% /tmp

/dev/mapper/VolGroup00-LogVol01

16G 2.6G 13G 18% /usr

/dev/mapper/VolGroup00-LogVol02

2.0G 503M 1.4G 27% /var

/dev/mapper/VolGroup00-LogVol03

992M 34M 908M 4% /opt/patrol

/dev/sda1 124M 19M 99M 16% /boot

tmpfs 187M 0 187M 0% /dev/shm

[root@server dev]# mount /local

[root@server dev]# mount /scratch

[root@server dev]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

992M 448M 493M 48% /

/dev/mapper/VolGroup00-LogVol05

2.0G 69M 1.8G 4% /tmp

/dev/mapper/VolGroup00-LogVol01

16G 2.6G 13G 18% /usr

/dev/mapper/VolGroup00-LogVol02

2.0G 503M 1.4G 27% /var

/dev/mapper/VolGroup00-LogVol03

992M 34M 908M 4% /opt/patrol

/dev/sda1 124M 19M 99M 16% /boot

tmpfs 187M 0 187M 0% /dev/shm

/dev/mapper/VolGroup01-LogVol00

55G 180M 54G 1% /local

/dev/mapper/VolGroup00-LogVol06

5.7G 140M 5.3G 3% /scratch

[root@server dev]# e2label /dev/

Display all 618 possibilities? (y or n)

[root@server dev]# e2label /dev/VolGroup01/LogVol00

/local

[root@server dev]# cat /etc/fstab

/dev/VolGroup00/LogVol00 / ext3 defaults 1 1

/dev/VolGroup00/LogVol05 /tmp ext3 defaults 1 2

/dev/VolGroup00/LogVol06 /scratch ext3 defaults 1 2

/dev/VolGroup00/LogVol01 /usr ext3 defaults 1 2

/dev/VolGroup00/LogVol02 /var ext3 defaults 1 2

/dev/VolGroup00/LogVol03 /opt/patrol ext3 defaults 1 2

LABEL=/boot /boot ext3 defaults 1 2

tmpfs /dev/shm tmpfs defaults 0 0

devpts /dev/pts devpts gid=5,mode=620 0 0

sysfs /sys sysfs defaults 0 0

proc /proc proc defaults 0 0

/dev/VolGroup00/LogVol04 swap swap defaults 0 0

LABEL=/local /local ext3 defaults 1 2

0 comments:

Post a Comment

 
;