Linux command exercise: Mount Fdisk swap dd to create a local loopback device

Source: Internet
Author: User
Tags hex code

Practice a

1, create a 1G partition, the file system is EXT4, the volume is labeled MyData, the block size is 1024, the reserved management space for the disk

3% of the partition requires that the brake be mounted to the/data directory, and automatically mounted devices are referenced using the volume label.

FDISK/DEV/SDA  

[Email protected] ~]# FDISK/DEV/SDA

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): n New Partition, if it is a new hard disk will prompt to create a new primary partition (P) or an extended partition (e)

First cylinder (2258-2611, default 2258): Enter the starting cylinder defaults

Using Default Value 2258

Last cylinder, +cylinders or +size{k,m,g} (2258-2611, default 2611): +1g Create a 1G partition

Command (M for help): t T modify partition type

Partition number (1-8): 8

Hex code (Type L to list codes): l l View System-supported partition types


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

Hex code (type L to list codes): 83 input partition type

Command (M for help): p shows the partitioned table that has been established

disk/dev/sda:21.5 GB, 21474836480 bytes

255 heads, Sectors/track, 2610 cylinders

Units = Cylinders of 16065 * 8225280 bytes

Sector size (logical/physical): bytes/512 bytes

I/O size (minimum/optimal): bytes/512 bytes

Disk Identifier:0x0001e9b8


Device Boot Start End Blocks Id System

/DEV/SDA1 * 1 204800 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 1046 8192000 Linux

/dev/sda3 1046 1556 4096000-up Linux

/DEV/SDA4 1556 2611 8477696 5 Extended

/dev/sda5 1556 1811 2048000-up Linux

/dev/sda6 1811 2066 2048000-up Linux

/dev/sda7 2066 2258 1536000, Linux Swap/solaris

/dev/sda8 2258 2389 1059691 -up Linux

SDA8 is just the newly created partition

Ommand (M for help): W Save exit new partition established successfully

The partition table has been altered!

Calling IOCTL () to re-read partition table.

[[email protected] ~]# partprobe partprobe notify kernel Reread partition table, let kernel recognize new partition

[Email protected] ~]# cat/proc/partitions

Major Minor #blocks name

8 0 20971520 SDA

8 1 204800 sda1

8 2 8192000 Sda2

8 3 4096000 Sda3

8 4 1 SDA4

8 5 2048000 Sda5

8 6 2048000 Sda6

8 7 1536000 Sda7

8 8 1024000 The SDA8 kernel has identified the new partition, only the partition can be formatted, mounted, and so on.

[[email protected] ~]# mke2fs-t ext4/dev/sda8 format/dev/sda8 partition as EXT4 type

[[email protected] test]#  mke2fs-l mydata  /dev/sda8     Set a new volume labeled MYDATA

[[email protected] test]# mke2fs-m 3/dev/sda8 reserved Partition 3% to the admin space

[email protected] test]# mke2fs-b 1024/DEV/SDA8 Set block size to 1024 bytes

The new partition is then written to the/etc/fstab document, which automatically mounts the boot, adding a line at the bottom of the document as follows:

label= ' MYDATA ' /data ext4 defaults 0 0

Implement volume label Auto Mount as MyData

Exercise Two

2, create a local loopback file/var/swaptemp/swapfile for swap, 512MB size required,

the volume label is swap-file and the switching device is automatically enabled on boot:

Mkdir/var/swaptemp

DD If=/dev/zero of=/var/swaptemp/swapfile bs=512m count=1

Mkswap Label=swap-file/var/swaptemp/swapfile

Vim/etc/fstab

/var/swaptemp/swapfile swap swap defaults 0 0 write/etc/fstab for automatic mount on boot


This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1868152

Linux command exercise: Mount Fdisk swap dd to create a local loopback device

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.