add new drive / partition linux (virtualbox)

– add new drive (virtualbox), my new drive is webdisk.qed (8GB)
webdisk

– start linux box
– check mounting hardisk


ub@svr:~$ df -k
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda1        2614880 1990860    492948  81% /
udev             1016984       4   1016980   1% /dev
tmpfs             205156     328    204828   1% /run
none                5120       0      5120   0% /run/lock
none             1025768       0   1025768   0% /run/shm

 

– check partition


ub@svr:~$ cat /proc/partitions
major minor  #blocks  name

   8        0    3145728 sda
   8        1    2621440 sda1
   8        2          1 sda2
   8        5     521216 sda5
   8       16    8388608 sdb
  11        0    1048575 sr0

 

sdb connected

– start fdisk

 ub@svr:~$ sudo fdisk /dev/sdb

 

– check if partition true


Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 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: 0xb29446a9

   Device Boot      Start         End      Blocks   Id  System

 

– create new partition


Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
Using default value 1
First sector (2048-16777215, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215):
Using default value 16777215

 

– check again


Command (m for help): p

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders, total 16777216 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: 0xb29446a9

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    16777215     8387584   83  Linux

 

– write partition


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

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

 

– read (again) partition


ub@svr:~$ cat /proc/partitions
major minor  #blocks  name

8        0    3145728 sda
8        1    2621440 sda1
8        2          1 sda2
8        5     521216 sda5
8       16    8388608 sdb
8       17    8387584 sdb1
11        0    1048575 sr0

– check with fdisk

ub@svr:~$ sudo fdisk -l

Disk /dev/sda: 3221 MB, 3221225472 bytes
255 heads, 63 sectors/track, 391 cylinders, total 6291456 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: 0x000e416a

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     5244927     2621440   83  Linux
/dev/sda2         5246974     6289407      521217    5  Extended
/dev/sda5         5246976     6289407      521216   82  Linux swap / Solaris

Disk /dev/sdb: 8589 MB, 8589934592 bytes
86 heads, 1 sectors/track, 195083 cylinders, total 16777216 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: 0x16dba2a4

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048    16777215     8387584   83  Linux

– format partition with ext4 extension


ub@svr:~$ sudo mkfs -t ext4 /dev/sdb1
mke2fs 1.42 (29-Nov-2011)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
524288 inodes, 2096896 blocks
104844 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

–  create dir for mounting


ub@svr:~$ mkdir /home/ub/websites
ub@svr:~$ ls
websites

– mounting otomatis at boot


ub@svr:~$ sudo nano /etc/fstab

# add this line
/dev/sdb1 /home/ub/websites ext4 defaults 1 2

– change owner to user


ub@svr:~$sudo chown ub websites

– mounting all partition


ub@svr:~$sudo mount -a

– check all volume


ub@svr:~/websites/myadmin$ df -k
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda1        2614880 1971904    511904  80% /
udev             1016984       4   1016980   1% /dev
tmpfs             205156     332    204824   1% /run
none                5120       0      5120   0% /run/lock
none             1025768       0   1025768   0% /run/shm
/dev/sdb1        8361296  278640   7663280   4% /home/ub/websites

– test create file

ub@svr:~$ echo "Ganteng" > websites/test2.txt
ub@svr:~$ ls -al websites
total 40
drwxr-xr-x 5 ub   root  4096 May 18 19:00 .
drwxr-xr-x 8 ub   ub    4096 May 18 18:18 ..
drwx------ 2 root root 16384 May 18 18:17 lost+found
-rw-rw-r-- 1 ub   ub       8 May 18 19:00 test2.txt

Published by

G3n1k

just to remember what i had known :)

One thought on “add new drive / partition linux (virtualbox)”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s