How to mount a hard disk under Linux

Source: Internet
Author: User

0. Load the virtual hard disk:

1. add disks to view disk status

[Email protected]/]# fdisk-l

disk/dev/sda:10.7 GB, 10737418240 bytes

255 heads, Sectors/track, 1305 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 * 151 1305 9277537+ Linux

/dev/sda2 1 1204843+ for the Linux swap

Partition table entries is not in disk order

disk/dev/sdb:5368 MB, 5368709120 bytes

255 heads, Sectors/track, 652 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

From the results of the query, there is a more/dev/sdb disk

2. Partitioning the/dev/sdb with Fdisk

[Email protected]/]# Fdisk/dev/sdb

Command (M for help): N

Command Action

E Extended

P primary partition (1-4)

P

Partition number (1-4): 1

First cylinder (1-652, default 1):

Using Default value 1

Last cylinder or +size or +sizem or +sizek (1-652, default 652):

Using Default value 652

Command (M for help): W

The partition table has been altered!

Calling IOCTL () to re-read partition table.

Syncing disks.

Look at the partition again, more than a/dev/sdb1 area, this 1 is what we specified earlier, if we specify 2, it becomes sdb2.

[Email protected]/]# fdisk-l

disk/dev/sda:10.7 GB, 10737418240 bytes

255 heads, Sectors/track, 1305 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 * 151 1305 9277537+ Linux

/dev/sda2 1 1204843+ for the Linux swap

Partition table entries is not in disk order

disk/dev/sdb:5368 MB, 5368709120 bytes

255 heads, Sectors/track, 652 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Device Boot Start End Blocks Id System

/DEV/SDB1 1 652 5237158+ Linux

[Email protected]/]#

3. Format the/DEV/SDB1 partition

[Email protected]/]# mkfs-t EXT3/DEV/SDB1

MKE2FS 1.35 (28-feb-2004)

Filesystem label=

OS Type:linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

655360 inodes, 1309289 blocks

65464 blocks (5.00%) reserved for the Super user

First Data block=0

Maximum filesystem blocks=1342177280

Groups block

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

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

Writing Inode Tables:done

Creating Journal (8192 blocks): Done

Writing superblocks and filesystem accounting Information:done

This filesystem would be automatically checked every mounts or

Whichever comes first. Use Tune2fs-c or-i to override.

4. Create a directory and hang the/DEV/SDB1 in the directory

[[email protected]/]# ls

Backup dev initrd media opt sbin sys usr

Bin etc Lib Misc proc SELinux tftpboot var

Boot home lost+found mnt root SRV tmp

[Email protected]/]# mkdir/u01

[[email protected]/]# ls

Backup dev initrd media opt sbin sys u01

Bin etc Lib misc proc SELinux tftpboot usr

Boot home lost+found mnt root SRV tmp var

[Email protected]/]# mount/dev/sdb1/u01

5. Verify that the mount is successful

[Email protected]/]# df-k

Filesystem 1k-blocks used Available use% mounted on

/DEV/SDA1 9131772 7066884 1601012 82%/

None 454256 0 454256 0%/dev/shm

/DEV/SDB1 5154852 43040 4849956 1%/backup

6. set up auto mount on boot

[Email protected]/]# Vi/etc/fstab

# This file was edited by Fstab-sync-see ' Man Fstab-sync ' for details

label=//ext3 Defaults 1 1

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

NONE/DEV/SHM TMPFS Defaults 0 0

NONE/PROC proc Defaults 0 0

None/sys Sysfs Defaults 0 0

Label=swap-sda2 swap swap defaults 0 0

/dev/sdb1/u01 ext3 defaults 0 0

/dev/hdc/media/cdrom Auto Pamconsole,exec,noauto,m

Anaged 0 0

/dev/fd0/media/floppy Auto Pamconsole,exec,noauto,m

Anaged 0 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.