我尝试使用脚本对硬盘驱动器进行分区,但在重新安装分区时遇到一些问题。 btrfs 和 ext4 都会发生这种情况。所以我认为问题是分区表,而不是文件系统本身。
由于我必须对多个驱动器进行分区,因此我编写了一个脚本。执行的命令始终在行之间突出显示。gdisk
有来自 STDIN 的输入。
分区显然有效,我可以安装分区一次,在其上创建一些文件并卸载它。但是,当我尝试再次安装它时,它不起作用,请参阅底部。
provision-backup-drive /dev/sdd USB-Eins --sudo --english --fs ext4
----------------------------------
env LC_ALL=C sudo gdisk /dev/sdd
----------------------------------
GPT fdisk (gdisk) version 0.8.8
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): Disk /dev/sdd: 312581808 sectors, 149.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 4AC00C3C-08A1-4AB5-BF89-3FC41083DBE2
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 312581774
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 100.0 MiB 8300 Linux filesystem
2 206848 312581774 149.0 GiB 8300 Linux filesystem
Command (? for help): This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N):
Command (? for help): Disk /dev/sdd: 312581808 sectors, 149.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 67723BF9-8005-46A1-A0A3-1F0EE4DA3743
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 312581774
Partitions will be aligned on 2048-sector boundaries
Total free space is 312581741 sectors (149.1 GiB)
Number Start (sector) End (sector) Size Code Name
Command (? for help): Partition number (1-128, default 1): First sector (34-312581774, default = 2048) or {+-}size{KMGTP}: Last sector (2048-312581774, default = 312581774) or {+-}size{KMGTP}: Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'
Command (? for help): Partition number (2-128, default 2): First sector (34-312581774, default = 206848) or {+-}size{KMGTP}: Last sector (206848-312581774, default = 312581774) or {+-}size{KMGTP}: Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'
Command (? for help): Disk /dev/sdd: 312581808 sectors, 149.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 67723BF9-8005-46A1-A0A3-1F0EE4DA3743
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 312581774
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 100.0 MiB 8300 Linux filesystem
2 206848 312581774 149.0 GiB 8300 Linux filesystem
Command (? for help):
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.
----------------------------------
env LC_ALL=C sudo mkfs.ext4 -L USB-Eins-info /dev/sdd1
----------------------------------
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=USB-Eins-info
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25688 inodes, 102400 blocks
5120 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
13 block groups
8192 blocks per group, 8192 fragments per group
1976 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
----------------------------------
env LC_ALL=C sudo mkfs.ext4 -L USB-Eins-data /dev/sdd2
----------------------------------
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=USB-Eins-data
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
9764864 inodes, 39046865 blocks
1952343 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1192 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, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
----------------------------------
env LC_ALL=C sudo fsck.ext4 /dev/sdd1
----------------------------------
e2fsck 1.42.9 (4-Feb-2014)
USB-Eins-info: clean, 11/25688 files, 8896/102400 blocks
----------------------------------
env LC_ALL=C sudo fsck.ext4 /dev/sdd2
----------------------------------
e2fsck 1.42.9 (4-Feb-2014)
USB-Eins-data: clean, 11/9764864 files, 660837/39046865 blocks
----------------------------------
env LC_ALL=C sudo mount -t ext4 /dev/sdd1 /mnt
----------------------------------
----------------------------------
env LC_ALL=C sudo mkdir /mnt/info
----------------------------------
----------------------------------
env LC_ALL=C sudo chown mu:mu /mnt/info
----------------------------------
----------------------------------
env LC_ALL=C sudo ls -l /mnt/
----------------------------------
total 13
drwxr-xr-x 2 mu mu 1024 Sep 21 20:36 info
drwx------ 2 root root 12288 Sep 21 20:36 lost+found
----------------------------------
env LC_ALL=C sudo umount /mnt
----------------------------------
----------------------------------
env LC_ALL=C sudo mount -t ext4 /dev/sdd1 /mnt
----------------------------------
mount: wrong fs type, bad option, bad superblock on /dev/sdd1,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
通过运行我的脚本创建的输出dmesg
如下:
[22396.667509] end_request: critical target error, dev sdd, sector 0
[22396.735970] sdd: sdd1 sdd2
[22397.464324] end_request: critical target error, dev sdd, sector 0
[22397.495326] end_request: critical target error, dev sdd, sector 0
[22402.586300] end_request: critical target error, dev sdd, sector 0
[22402.589245] end_request: critical target error, dev sdd, sector 0
[22403.083901] end_request: critical target error, dev sdd, sector 0
[22403.088146] end_request: critical target error, dev sdd, sector 0
[22403.193658] end_request: critical target error, dev sdd, sector 0
[22403.199673] end_request: critical target error, dev sdd, sector 0
[22403.237060] EXT4-fs (sdd1): mounted filesystem with ordered data mode. Opts: (null)
[22403.343704] end_request: critical target error, dev sdd, sector 100372
[22403.343721] Aborting journal on device sdd1-8.
[22403.350210] EXT4-fs error (device sdd1): ext4_put_super:791: Couldn't clean up the journal
[22403.350216] EXT4-fs (sdd1): Remounting filesystem read-only
[22403.439137] end_request: critical target error, dev sdd, sector 0
[22403.439150] JBD2: recovery failed
[22403.439155] EXT4-fs (sdd1): error loading journal
BTFS
provision-backup-drive /dev/sdd USB-Eins --sudo --english --fs btrfs
----------------------------------
env LC_ALL=C sudo gdisk /dev/sdd
----------------------------------
GPT fdisk (gdisk) version 0.8.8
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Command (? for help): Disk /dev/sdd: 312581808 sectors, 149.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 57D4C65B-E062-4990-8FB5-15D6E77E1CDE
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 312581774
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 100.0 MiB 8300 Linux filesystem
2 206848 312581774 149.0 GiB 8300 Linux filesystem
Command (? for help): This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N):
Command (? for help): Disk /dev/sdd: 312581808 sectors, 149.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 44E42DFC-45CA-4056-BC27-9D51BF975E4E
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 312581774
Partitions will be aligned on 2048-sector boundaries
Total free space is 312581741 sectors (149.1 GiB)
Number Start (sector) End (sector) Size Code Name
Command (? for help): Partition number (1-128, default 1): First sector (34-312581774, default = 2048) or {+-}size{KMGTP}: Last sector (2048-312581774, default = 312581774) or {+-}size{KMGTP}: Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'
Command (? for help): Partition number (2-128, default 2): First sector (34-312581774, default = 206848) or {+-}size{KMGTP}: Last sector (206848-312581774, default = 312581774) or {+-}size{KMGTP}: Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): Changed type of partition to 'Linux filesystem'
Command (? for help): Disk /dev/sdd: 312581808 sectors, 149.1 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 44E42DFC-45CA-4056-BC27-9D51BF975E4E
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 312581774
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 100.0 MiB 8300 Linux filesystem
2 206848 312581774 149.0 GiB 8300 Linux filesystem
Command (? for help):
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.
----------------------------------
env LC_ALL=C sudo mkfs.btrfs -f -L USB-Eins-info /dev/sdd1
----------------------------------
SMALL VOLUME: forcing mixed metadata/data groups
WARNING! - Btrfs v3.12 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using
Turning ON incompat feature 'mixed-bg': mixed data and metadata block groups
Turning ON incompat feature 'extref': increased hardlink limit per file to 65536
Created a data/metadata chunk of size 8388608
fs created label USB-Eins-info on /dev/sdd1
nodesize 4096 leafsize 4096 sectorsize 4096 size 100.00MiB
Btrfs v3.12
----------------------------------
env LC_ALL=C sudo mkfs.btrfs -f -L USB-Eins-data /dev/sdd2
----------------------------------
WARNING! - Btrfs v3.12 IS EXPERIMENTAL
WARNING! - see http://btrfs.wiki.kernel.org before using
Turning ON incompat feature 'extref': increased hardlink limit per file to 65536
fs created label USB-Eins-data on /dev/sdd2
nodesize 16384 leafsize 16384 sectorsize 4096 size 148.95GiB
Btrfs v3.12
----------------------------------
env LC_ALL=C sudo btrfsck /dev/sdd1
----------------------------------
Checking filesystem on /dev/sdd1
UUID: 97cc058a-0476-408a-aefa-56867340f85c
checking extents
checking free space cache
cache and super generation don't match, space cache will be invalidated
checking fs roots
checking csums
checking root refs
found 28672 bytes used err is 0
total csum bytes: 0
total tree bytes: 28672
total fs tree bytes: 8192
total extent tree bytes: 4096
btree space waste bytes: 23766
file data blocks allocated: 0
referenced 0
Btrfs v3.12
----------------------------------
env LC_ALL=C sudo btrfsck /dev/sdd2
----------------------------------
Checking filesystem on /dev/sdd2
UUID: fdfe481f-16b0-450d-a93c-4cfbcc645f23
checking extents
checking free space cache
cache and super generation don't match, space cache will be invalidated
checking fs roots
checking csums
checking root refs
found 114688 bytes used err is 0
total csum bytes: 0
total tree bytes: 114688
total fs tree bytes: 32768
total extent tree bytes: 16384
btree space waste bytes: 108891
file data blocks allocated: 0
referenced 0
Btrfs v3.12
----------------------------------
env LC_ALL=C sudo mount -t btrfs /dev/sdd1 /mnt
----------------------------------
mount: /dev/sdd1: can't read superblock
的输出dmesg
如下:
[22463.224990] end_request: critical target error, dev sdd, sector 0
[22463.297823] sdd: sdd1 sdd2
[22463.545040] end_request: critical target error, dev sdd, sector 0
[22463.818478] end_request: critical target error, dev sdd, sector 0
[22463.908702] end_request: critical target error, dev sdd, sector 0
[22463.991087] end_request: critical target error, dev sdd, sector 0
[22464.018016] btrfs: device label USB-Eins-info devid 1 transid 4 /dev/sdd1
[22464.028207] btrfs: disk space caching is enabled
[22464.049798] btrfs: creating UUID tree
[22464.057085] end_request: critical target error, dev sdd, sector 0
[22464.057165] btrfs: bdev /dev/sdd1 errs: wr 0, rd 0, flush 1, corrupt 0, gen 0
[22464.057170] BTRFS error (device sdd1) in write_all_supers:3382: errno=-5 IO failure (errors while submitting device barriers.)
[22464.057173] BTRFS warning (device sdd1): Skipping commit of aborted transaction.
[22464.057174] ------------[ cut here ]------------
[22464.057386] WARNING: CPU: 1 PID: 20676 at /build/buildd/linux-3.13.0/fs/btrfs/super.c:254 __btrfs_abort_transaction+0x50/0x110 [btrfs]()
[22464.057399] btrfs: Transaction aborted (error -5)
[22464.057400] Modules linked in: ipt_MASQUERADE nf_nat_h323 nf_conntrack_h323 nf_nat_pptp nf_nat_proto_gre nf_conntrack_pptp nf_conntrack_proto_gre nf_nat_tftp nf_conntrack_tftp nf_nat_sip nf_conntrack_sip nf_nat_irc nf_conntrack_irc iptable_nat nf_nat_ipv4 usb_storage hid_generic pci_stub vboxpci(OF) vboxnetadp(OF) vboxnetflt(OF) vboxdrv(OF) ip6t_REJECT xt_hl ip6t_rt wacom nf_conntrack_ipv6 nf_defrag_ipv6 uvcvideo videobuf2_vmalloc videobuf2_memops videobuf2_core videodev ipt_REJECT xt_LOG xt_limit intel_rapl xt_tcpudp x86_pkg_temp_thermal xt_addrtype intel_powerclamp coretemp nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack kvm_intel ip6table_filter ip6_tables kvm nf_conntrack_netbios_ns nf_conntrack_broadcast nf_nat_ftp nf_nat nf_conntrack_ftp crct10dif_pclmul nf_conntrack iptable_filter crc32_pclmul ghash_clmulni_intel ip_tables x_tables aesni_intel aes_x86_64 lrw gf128mul glue_helper ablk_helper cryptd arc4 joydev snd_hda_codec_hdmi iwldvm serio_raw mac80211 snd_hda_codec_conexant thinkpad_acpi nvram bnep rfcomm bluetooth snd_seq_midi lpc_ich iwlwifi snd_hda_intel snd_seq_midi_event snd_hda_codec snd_hwdep cfg80211 snd_rawmidi snd_pcm snd_seq snd_page_alloc snd_seq_device mei_me mei snd_timer snd binfmt_misc parport_pc ppdev soundcore lp parport mac_hid btrfs xor raid6_pq libcrc32c usbhid hid i915 i2c_algo_bit psmouse drm_kms_helper e1000e ahci drm sdhci_pci libahci ptp sdhci pps_core wmi video
[22464.057465] CPU: 1 PID: 20676 Comm: mount Tainted: GF W O 3.13.0-35-generic #62-Ubuntu
[22464.057466] Hardware name: LENOVO 4298PQ1/4298PQ1, BIOS 8DET56WW (1.26 ) 12/01/2011
[22464.057468] 0000000000000009 ffff880211faba30 ffffffff8171e320 ffff880211faba78
[22464.057470] ffff880211faba68 ffffffff8106775d 00000000fffffffb ffff88020f0b7000
[22464.057473] ffff880165de2140 ffffffffa02dde90 000000000000060b ffff880211fabac8
[22464.057475] Call Trace:
[22464.057480] [<ffffffff8171e320>] dump_stack+0x45/0x56
[22464.057483] [<ffffffff8106775d>] warn_slowpath_common+0x7d/0xa0
[22464.057487] [<ffffffff810677cc>] warn_slowpath_fmt+0x4c/0x50
[22464.057497] [<ffffffffa0241f00>] __btrfs_abort_transaction+0x50/0x110 [btrfs]
[22464.057509] [<ffffffffa026bebe>] cleanup_transaction+0x6e/0x290 [btrfs]
[22464.057514] [<ffffffff810aafd0>] ? prepare_to_wait_event+0x100/0x100
[22464.057525] [<ffffffffa026ce3a>] btrfs_commit_transaction+0x6ea/0x970 [btrfs]
[22464.057538] [<ffffffffa029278a>] btrfs_create_uuid_tree+0x5a/0x100 [btrfs]
[22464.057549] [<ffffffffa026a784>] open_ctree+0x1c14/0x1f80 [btrfs]
[22464.057558] [<ffffffffa024156e>] btrfs_mount+0x63e/0x800 [btrfs]
[22464.057629] [<ffffffff8116f5aa>] ? pcpu_alloc+0x7da/0xa00
[22464.057636] [<ffffffff811c1079>] mount_fs+0x39/0x1b0
[22464.057640] [<ffffffff8116f7e0>] ? __alloc_percpu+0x10/0x20
[22464.057644] [<ffffffff811dc357>] vfs_kern_mount+0x67/0x110
[22464.057649] [<ffffffff811debb4>] do_mount+0x244/0xb20
[22464.057653] [<ffffffff8116a7cb>] ? strndup_user+0x4b/0xf0
[22464.057655] [<ffffffff811df783>] SyS_mount+0x83/0xc0
[22464.057659] [<ffffffff8172ed6d>] system_call_fastpath+0x1a/0x1f
[22464.057661] ---[ end trace 76c5beab44d82343 ]---
[22464.057663] BTRFS error (device sdd1) in cleanup_transaction:1547: errno=-5 IO failure
[22464.057666] delayed_refs has NO entry
[22464.057676] btrfs: failed to create the UUID tree -5
[22464.057682] btrfs: commit super ret -30
[22464.097955] btrfs: open_ctree failed
[22464.355109] btrfs: device label USB-Eins-data devid 1 transid 4 /dev/sdd2
[22464.376997] btrfs: device label USB-Eins-data devid 1 transid 4 /dev/sdd2
这大概是对我的首先要对其进行分区的问题,但我不知道为什么我可以安装它一次。
答案1
我最终扔掉了驱动器。新驱动不存在这样的问题。