AI智能
改变未来

Linux挂存储


1 查看存储是否已经分配

[root@localhost]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x0002f978

 

Device Boot      Start      End     Blocks      Id      System

/dev/sda1   *    1          131     1048576    83      Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2        131         2611    19921920    8e      Linux LVM

 

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 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

 

2 对/dev/sdb分区

[root@localhost home]# 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 0x2ae1db89.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won\’t be recoverable.

 

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, +cylinders or +size{K,M,G} (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.

 

3 查看分区

[root@localhost]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 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: 0x0002f978

 

Device Boot      Start      End     Blocks      Id      System

/dev/sda1   *    1          131     1048576    83      Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2        131         2611    19921920    8e      Linux LVM

 

Disk /dev/sdb: 5368 MB, 5368709120 bytes

255 heads, 63 sectors/track, 652 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: 0x2ae1db89

 

Device Boot      Start      End     Blocks      Id      System

/dev/sdb1        1          652     5237158+    83      Linux

 

4 格式化分区

[root@localhost]# mkfs -t ext4 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

文件系统标签=

操作系统:Linux

块大小=4096 (log=2)

分块大小=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

327680 inodes, 1309289 blocks

65464 blocks (5.00%) reserved for the super user

第一个数据块=0

Maximum filesystem blocks=1342177280

40 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

 

正在写入inode表: 完成                           

Creating journal (32768 blocks): 完成

Writing superblocks and filesystem accounting information: 完成

 

This filesystem will be automatically checked every 28 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

5 挂载分区

[root@localhost]# mount /dev/sda1 /opt

 

6 查看分区是否挂载成功

[root@localhost]# df -h

文件系统                       容量    已用    可用    已用%%    挂载点

/dev/mapper/VolGroup-lv_root   17G     5.4G    11G     34%       /

tmpfs                          932M    100K    932M    1%        /dev/shm

/dev/sda1                      1008M   56M     901M    6%        /boot

/dev/sdb1                      5.0G    139M    4.6G    3%        /opt

 

7 配置自动挂载

配置文件,在最下面添加以下信息:

[root@localhost]# vi /etc/fstab

/dev/sdb1               /opt                 ext4    defaults        0 0

赞(0) 打赏
未经允许不得转载:爱站程序员基地 » Linux挂存储