Linux add hard disk with Fdisk partition, MKE2FS formatted partition, auto mount

Source: Internet
Author: User
Tags ming uuid

The Fdisk tool can only partition disks below 2T, using parted partitions above 2T


First, use FDISK to partition the specified hard disk

[Email protected] ~]# 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 0x21248295.
Changes'll remain in memory only, until the decide to write them.
After that, of course, the previous content won ' t is recoverable.

Warning:invalid flag 0x0000 of partition Table 4 would be a corrected by W (rite)

Warning:dos-compatible mode is deprecated. It ' s strongly recommended to
Switch off the mode (command ' C ') and change display units to
Sectors (Command ' u ').

Command (M for help): P

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x21248295

Device Boot Start End Blocks Id System

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):


1. Create a primary partition

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-652, default 1): 1
Last cylinder, +cylinders or +size{k,m,g} (1-652, default 652): +1g

Command (M for help): P

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x21248295

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1060258+ Linux


2. Create an extended partition
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
E
Partition number (1-4): 2
First cylinder (133-652, default 133):
Using Default Value 133
Last cylinder, +cylinders or +size{k,m,g} (133-652, default 652): +1g

Command (M for help): P

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x21248295

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1060258+ Linux
/DEV/SDB2 133 1060290 5 Extended


3. Creating Logical partitions

Command (M for help): N
Command Action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (133-264, default 133):
Using Default Value 133
Last cylinder, +cylinders or +size{k,m,g} (133-264, default): +800m

Command (M for help): P

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x21248295

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1060258+ Linux
/DEV/SDB2 133 1060290 5 Extended
/DEV/SDB5 133 235 827316-Up Linux


Command (M for help): W
The partition table has been altered!

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



4. Display partition type ID
Command (M for help): l

0 Empty NEC DOS bayi minix/old Lin BF Solaris
1 FAT12 Plan 9 swap/so C1 drdos/sec (fat-
2 Xenix root 3c partitionmagic Linux C4 drdos/sec (fat-
3 Xenix usr Venix 80286 os/2 hidden c:c6 drdos/sec (fat-
4 FAT16 <32m PPC PReP Boot-up Linux extended C7 Syrinx
5 Extended SFS, NTFS volume set da non-fs data
6 FAT16 4d qnx4.x NTFS Volume set db cp/m/CTOS/.
7 Hpfs/ntfs 4e qnx4.x 2nd part of the Linux plaintext de Dell Utility
8 AIX 4f qnx4.x 3rd part 8e Linux LVM DF bootit
9 AIX bootable Ontrack DM Amoeba E1 DOS Access
A os/2 Boot manag Wuyi ontrack DM6 Aux 94 Amoeba BBT E3 DOS r/o
b W95 FAT32 cp/m 9f bsd/os e4 speedstor
C W95 FAT32 (LBA) Ontrack DM6 Aux A0 IBM Thinkpad hi EB BeOS FS
E W95 FAT16 (LBA) OnTrackDM6 a5 FreeBSD ee GPT
F W95 Ext ' d (LBA) ez-drive a6 OpenBSD ef EFI (fat-12/16/
Ten OPUS Bow A7 NeXTSTEP f0 linux/pa-risc b
One Hidden FAT12 5c Priam edisk A8 Darwin UFS F1 SpeedStor
Compaq diagnost speedstor A9 NetBSD f4 SpeedStor
Hidden FAT16 <3, GNU HURD or Sys ab Darwin boot F2 DOS Secondary
Hidden FAT16 Novell Netware af hfs/hfs+ fb VMware VMFS
Hidden hpfs/ntf Novell Netware b7 BSDI FS FC VMware Vmkcore
AST smartsleep disksecure Mult b8 BSDI swap fd Linux RAID auto
1b Hidden W95 FAT3 pc/ix bb Boot Wizard hid Fe lanstep
1c Hidden W95 FAT3, Minix be Solaris boot ff BBT
1e Hidden W95 FAT1

Command (M for help):

[email protected] ~]# fdisk-l/dev/sdb

disk/dev/sdb:5368 MB, 5368709120 bytes
255 heads, Sectors/track, 652 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk identifier:0x21248295

Device Boot Start End Blocks Id System
/DEV/SDB1 1 1060258+ Linux
/DEV/SDB2 133 1060290 5 Extended
/DEV/SDB5 133 235 827316-Up Linux


5. View File System type

[Email protected] ~]# Cat/etc/filesystems
Ext4
Ext3
Ext2
Nodev proc
Nodev devpts
iso9660
Vfat
HfS
Hfsplus



Second, format the partition

1, using MKFS.EXT4 format/DEV/SDB5 (method one)

[Email protected] ~]# MKFS.EXT4/DEV/SDB5
MKE2FS 1.41.12 (17-may-2010)
Filesystem label=
OS Type:linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
51744 inodes, 206829 blocks
10341 blocks (5.00%) reserved for the Super user
First Data block=0
Maximum filesystem blocks=213909504
7 Block groups
32768 blocks per group, 32768 fragments per group
7392 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840

Writing Inode Tables:done
Creating Journal (4096 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.


2. Format the partition using Mke2fs (method two)

[Email protected] ~]# mke2fs-t ext4-b 2048-m 1-l ming/dev/sdb1

-B Specify block (block) size

-m specifies reserved n% space

-L Label

[Email protected] ~]# mke2fs-t ext4-b 2048-m 1-l ming/dev/sdb1
MKE2FS 1.41.12 (17-may-2010)
Filesystem label=ming
OS Type:linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
66528 inodes, 530128 blocks
5301 Blocks (1.00%) reserved for the Super user
First Data block=0
Maximum filesystem blocks=537919488
Block groups
16384 blocks per group, 16384 fragments per group
Inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368

Writing Inode Tables:done
Creating Journal (16384 blocks): Done
Writing superblocks and filesystem accounting Information:done

This filesystem'll be automatically checked every Notoginseng mounts or
Whichever comes first. Use Tune2fs-c or-i to override.


Third, Mount

1. Manual Mounting

[Email protected] ~]# mount/dev/sdb5/mnt/
[Email protected] ~]# DF-HT
Filesystem Type Size used Avail use% mounted on
/dev/sda3 ext4 8.7G 926M 7.4G 11%/
Tmpfs tmpfs 491M 0 491M 0%/dev/shm
/DEV/SDA1 ext4 194M 27M 158M 15%/boot
/DEV/SDB5 ext4 796M 17M 739M 3%/mnt


[[email protected] ~]# mount-o noatime,rw/dev/sdb1/home/ming/disk1//noatime do not change read time


2, automatic mount, modify the/etc/fstab file

[Email protected] ~]# Blkid
/dev/sda1:uuid= "AD1CFBB0-1621-4B2C-B10A-F2EDE0D863BC" type= "Ext4"
/dev/sda2:uuid= "2b68ad5b-f328-4cd1-8d3d-a21b19574321" type= "swap"
/dev/sda3:uuid= "7A56F94A-8C3F-4B2F-8CF3-A68E901D5CAA" type= "Ext4"
/dev/sdb1:label= "Ming" uuid= "48cc8e42-98c3-46d0-9895-b04e073b39bd" type= "Ext4"
/dev/sdb5:uuid= "42348B39-109F-49C6-B34C-C5D2CCFAD5A2" type= "Ext4"


[Email protected] ~]# Vim/etc/fstab
/dev/sdb5/mnt ext4 Defaults 0 0 (whether backup, whether detected, 0 means no)


Defaults=rw,suid,dev,exec,auto,nouser,async/sync



3, boot automatically loaded configuration file/etc/rc.local, storage need to boot automatic loading command
[Email protected] ~]# ls/etc/rc.local
/etc/rc.local


[Email protected] ~]# vim/etc/rc.local

Mount/dev/sdb1/home/ming/disk1


[email protected] ~]# mount
/dev/sda3 on/type ext4 (rw)
Proc On/proc type proc (rw)
Sysfs On/sys type SYSFS (rw)
Devpts on/dev/pts type devpts (rw,gid=5,mode=620)
Tmpfs ON/DEV/SHM type TMPFS (rw)
/DEV/SDA1 on/boot type EXT4 (rw)
None On/proc/sys/fs/binfmt_misc type Binfmt_misc (rw)
/DEV/SDB5 on/mnt type EXT4 (rw)
/DEV/SDB1 on/home/ming/disk1 type EXT4 (rw,noatime)


Linux add hard disk with Fdisk partition, MKE2FS formatted partition, auto mount

Related Article

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.