Tuesday, October 07, 2014

Mount block device

How to mount a new block device (CentOS)

# Check current status: shows no partition info and disk ID=0x0

sudo fdisk -l

Disk /dev/xvdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

# Create a partition. Answer prompts as indicated
sudo fdisk /dev/xvdc
n # new partition
p # primary
1 # partition no.
<enter> # accept start cyclinder default
<enter> # accept end cyclinder default (take whole device!)
w # write partition

# Verify. fdisk should show new partition info
sudo fdisk -l

Disk /dev/xvdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xb7719266

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdc1               1       26108   209712478+  83  Linux


# Format new device
sudo mkfs -t ext3 /dev/xvdc1

# Mount it
[ ! -d /data ] && sudo mkdir /data
sudo mount /dev/xvdc1 /data

# Make permanent
sudo nano /etc/fstab
# edit to add:
/dev/xvdc1            /data                    ext3    defaults,noatime,barrier=0      1 1

No comments: