Home > linux基础 > linode Rebuild后,不更改现有分区如何新增分区?

linode Rebuild后,不更改现有分区如何新增分区?

[[email protected] ~]# fdisk -l

Disk /dev/xvda: 20.9 GB, 20937965568 bytes
255 heads, 63 sectors/track, 2545 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

Disk /dev/xvda doesn’t contain a valid partition table

Disk /dev/xvdb: 536 MB, 536870912 bytes
255 heads, 63 sectors/track, 65 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

Disk /dev/xvdb doesn’t contain a valid partition table
[[email protected] ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda              20G  571M   18G   4% /
tmpfs                 249M  108K  249M   1% /dev/shm
[[email protected] ~]# df -aT
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/xvda     ext3    20125740    584172  18517712   4% /
/proc         proc           0         0         0   –  /proc
sysfs        sysfs           0         0         0   –  /sys
devpts      devpts           0         0         0   –  /dev/pts
tmpfs        tmpfs      254252       108    254144   1% /dev/shm
none   binfmt_misc           0         0         0   –  /proc/sys/fs/binfmt_misc

上面是linode管理后台rebuild系统后,默认的分区,也就是仅/和/swap。在不更改现有磁盘分区的基础上如何新增分区呢?使用dd,loop挂载特殊设备即可实现。当然,不通过命令,通过linode管理后台直接添加分区更简洁,以下教程仅仅为学习linux如何通过dd命令和loop特殊设备挂载。

[[email protected] /]# mkdir linode_backup
[[email protected] /]# ls
bin   dev  home  linode_backup  media  opt   root  selinux  sys  usr
boot  etc  lib   lost+found     mnt    proc  sbin  srv      tmp  var
[[email protected] /]# dd if=/dev/zero of=linode_backup bs=1M count=10240
dd: opening `linode_backup’: Is a directory
[[email protected] /]# cd linode_backup
[[email protected] linode_backup]# cd ..
[[email protected] /]# dd if=/dev/zero of=/linode_backup/backup bs=1M count=10240
10240+0 records in
10240+0 records out
10737418240 bytes (11 GB) copied, 117.394 s, 91.5 MB/s
[[email protected] /]# mkfs -t ext3 /linode_backup/backup
mke2fs 1.41.12 (17-May-2010)
/linode_backup/backup is not a block special device.
Proceed anyway? (y,n) y
warning: Unable to get device geometry for /linode_backup/backup
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 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

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

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

接下来挂载刚刚格式化的大文件分区即可完成重新分区。

[[email protected] /]# mkdir backup
[[email protected] /]# mount -o loop /linode_backup/backup  /backup
[[email protected] /]# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/xvda             20125740  11080204   8021680  59% /
tmpfs                   254252       108    254144   1% /dev/shm
/linode_backup/backup
                      10321208    154232   9642688   2% /backup
[[email protected] /]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/xvda              20G   11G  7.7G  59% /
tmpfs                 249M  108K  249M   1% /dev/shm
/linode_backup/backup
                      9.9G  151M  9.2G   2% /backup


若非注明,本博客内容均为原创或翻译自Linode Library,教程默认Centos为linux发行版,转载请注明转自linode中文教程www.linode.im。linode中文教程QQ群:185393826,一起讨论linode及linux,linode中文教程、linode代购、linode合租、linode推介、linode返佣、linode优惠。日本VPS、美国VPS、海外独立服务器代购均在linode.im。

Categories: linux基础 Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.