Menambahkan disk di linux via console

Menambahkan disk di linux

Penambahan dilakukan pada server virtual mesin (netmon). Penambahan tidak ditambahkan di lvm nya, tapi hanya penambahan biasa.

1. setelah dilakukan penambahan disk, booting kembali OS linuxnya

2. selanjutnya, periksa menggunakan dmesg, apakah disk yang baru saja kita tambahkan sudah dikenali atau belum
# dmesg | grep disk
RAMDISK driver initialized: 16 RAM disks of 16384K size 4096 blocksize
sd 0:0:0:0: [sda] Attached SCSI disk
sd 0:0:1:0: [sdb] Attached SCSI disk


terdapat informasi di atas, 2 scsi disk, yaitu sda dan sdb. karena sda merupakan disk yang telah ada, maka kita akan menginisialisasikan disk b.

3. buat direktory untuk mounting
# mkdir /disk

4. cek disk system

# fdisk -ls

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0006bc68

Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 1958 15526822+ 8e Linux LVM

Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/dm-0: 14.7 GB, 14763950080 bytes
255 heads, 63 sectors/track, 1794 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x30307800

Disk /dev/dm-1 doesn't contain a valid partition table

/dev/sdb sudah dikenali oleh linux, tapi belum memiliki tabel partisi.


5. Install tabel partisi di linux menggunakan fdisk

# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x17a21d03.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.


The number of cylinders for this disk is set to 2610.
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)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help):
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):
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-2610, default 2610):
Using default value 2610

Command (m for help):
Command (m for help): v
13452 unallocated sectors

Command (m for help): p

Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x17a21d03

Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux

Command (m for help):
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.


6. Cek kembali, apakah disk telah dikenali atau belum

# fdisk -ls

Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0006bc68

Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 1958 15526822+ 8e Linux LVM

Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x17a21d03

Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793+ 83 Linux
Disk /dev/dm-0: 14.7 GB, 14763950080 bytes
255 heads, 63 sectors/track, 1794 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/dm-0 doesn't contain a valid partition table

Disk /dev/dm-1: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x30307800

Disk /dev/dm-1 doesn't contain a valid partition table

terlihati di atas, tabel partisi /dev/sdb sudah dikenali oleh linux. tahap selanjutnya adalah menambahkan file systemnya


7. Format File system disk agar bisa ditulis dan dibaca

# mkfs.ext3 /dev/sdb
mke2fs 1.40.2 (12-Jul-2007)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2621440 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 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

Writing inode tables: done
Creating journal (32768 blocks):
done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 33 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.


8. Petakan disk tadi pada direktory yang telah kita buat. agar nantinya kita tidak perlu repot memetakan ulang. pemetaan disk, dapat dilakukan di /etc/fstab

tambakan baris berikut di /etc/fstab
/dev/sdb /disk ext3 defaults 1 1


/dev/sdb -> disk yang akan di petakan (di mount)
/disk -> lokasi disk akan dipetakan (di mounting)
ext3 -> jenis file system yang akan digunakan
default -> opsi partisi
1 1 -> partisi akan dihidupkan pada saat system di boot.


9. jika sudah diletakkan di /etc/fstab, langkah selanjutnya adalah memanggil partisi tadi
# mount -a


10. cek apakah sudah sukses di mount atau tidak
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
14G 9.7G 3.0G 77% /
/dev/sda1 190M 13M 169M 7% /boot
tmpfs 508M 0 508M 0% /dev/shm
/dev/sdb 20G 173M 19G 1% /disk

Komentar

Postingan Populer