AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[parted](unix)

Martin Hope
midnite
Asked: 2022-06-07 08:15:22 +0800 CST

在 /dev/mapper/ 上分开,Ignore 和 Cancel 有什么区别?

  • 1

我正在使用parted分区一个/dev/mapper/luks_device. 我知道之后我必须使用kpartx加载分区映射(参考这个线程)。但是,在partedby创建分区时mkpart swap 1 500,我像往常一样收到以下错误。

(parted) mkpart swap 1 500
Error: Partition(s) 1 on /dev/mapper/luks_device have been written, but we have been
unable to inform the kernel of the change, probably because it/they are in use.  As a
result, the old partition(s) will remain in use.  You should reboot now before making
further changes.
Ignore/Cancel? 

忽略和取消是什么意思?他们有什么区别?即使我键入“取消”,仍然会创建分区。

parted device-mapper
  • 1 个回答
  • 74 Views
Martin Hope
user3414682
Asked: 2019-05-09 02:00:48 +0800 CST

文件可以在分区表和文件系统重建中存活吗?

  • 0

通过GNU parted我创建了新的 DOS 分区表,一个分区和mkfs.ext2该分区上的 ext2 文件系统。我将一些文件复制到该分区。之后,我再次在同一个 HDD 上创建了新的 DOS 分区表、一个分区和 ext2 文件系统。当我挂载这个分区时,一些文件仍然存在。文件是否有可能在分区和文件系统重建中幸存下来?

parted ext2
  • 1 个回答
  • 43 Views
Martin Hope
programmer
Asked: 2019-05-08 09:08:00 +0800 CST

分区错误(Fdisk/Parted)

  • 4

我正在使用parted命令创建一个分区,并使用mkpart选项创建一个新的主分区。但是我在执行此操作时收到了不寻常的错误消息。这是我的输出:

(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 729GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number  Start   End     Size    Type      File system  Flags
 1      1049kB  300GB   300GB   primary   ext4         boot

(parted) mkpart
Partition type? primary/extended? primary
File system type? ext4
Start? 1050
End? 30000
Warning: You requested a partition from 1050MB to 30.0GB (sector 2050781..58593750). The closest location we can manage is 300GB to 300GB (sector 585936896..585936896).
Is this still acceptable to you?
Yes/No?
  • 我从 1050 开始(因为前一个分区从 1049 开始),我按照我的意愿在 30GB 结束(30000MB)

  • 有人告诉我,我必须将 Start 值设置为比前一个分区的起始值大一,并且我应该以我想要的 MB 大小执行结束值,因为 parted 默认使用 MB。

partition parted
  • 1 个回答
  • 1141 Views
Martin Hope
plugwash
Asked: 2019-03-17 07:27:42 +0800 CST

分区分区驱动器,最后带有小分区

  • 1

我想从脚本中对驱动器进行分区,以便有一个大分区填充大部分驱动器,然后是一个小分区。到目前为止,我已经想出了。

parted -s -- /dev/sda mklabel msdos
parted -s -a optimal -- /dev/sda mkpart primary 1MiB -10GiB  
parted -s -a optimal -- /dev/sda mkpart primary -10GiB -1s

不幸的是,最后一个命令不起作用。它似乎parted会在分区结束时接受负数,但在开始时不接受。我该如何解决这个问题?

scripting parted
  • 1 个回答
  • 277 Views
Martin Hope
Tim
Asked: 2019-02-21 15:23:43 +0800 CST

可以分开显示已使用和可用的尺寸作为 gparted 吗?

  • 0

gparted 据说是 parted 的 GUI 前端。

为什么 parted 不能像 gparted 那样显示每个分区的已用和可用大小?

如果分开可以,我怎样才能让它显示这些信息?

如果没有,gparted 是如何做到的?

$ sudo parted -l
[sudo] password for t: 
Model: ATA ST1000LM014-1EJ1 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system     Name  Flags
 1      1049kB  2097kB  1049kB                        bios_grub
 2      2097kB  16.0GB  16.0GB  linux-swap(v1)
 4      116GB   716GB   600GB   ext4
 3      716GB   1000GB  284GB   ext4

在此处输入图像描述

parted gparted
  • 1 个回答
  • 279 Views
Martin Hope
Tim
Asked: 2019-02-19 08:11:40 +0800 CST

`parted resizepart` 和 `resize2fs` 不会修改或删除分区上的现有文件吗?

  • 0

parted's命令是否resizepart默认不修改或删除分区上的现有文件?此外,它是否永远不会修改或删除分区上的现有文件(即使通过某些选项)?

类似的问题resize2fs?

谢谢。

partition parted
  • 1 个回答
  • 2214 Views
Martin Hope
Alex Darrell
Asked: 2018-12-28 06:38:37 +0800 CST

如何在前一个分区的末尾使用 GNU Parted 创建一个分区?

  • 1

我有一个 8 TB 的硬盘,上面有两个分区:3 TB 和 1 TB,所以剩余的 4 TB 是免费的。我想创建一个跨越磁盘其余部分的第三个分区。在早期使用 fdisk 创建新分区时,程序会自动提供一个起始位置,该起始位置正好在前一个分区结束之后。但是 GNU parted 不提供这样的选项。

驱动器的布局如下所示:

GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p
Model: ATA WDC WD80EFZX-68U (scsi)
Disk /dev/sdc: 8002GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  3001GB  3001GB               primary
 2      3001GB  4001GB  1000GB               primary

所有指南都建议使用(在这种情况下)“4001GB”作为分区的开始,“-1”作为分区的结束。在这种情况下,“4001GB”边界对我来说似乎有点模棱两可。虽然 1 GB 在 TB 的范围内是微不足道的,但 OCD-me 希望使用整个磁盘。

因此我的问题是:

有没有一种明智的方法来使用 GNU Parted 创建一个新分区,使得新分区紧跟前一个分区,并考虑到适当的对齐?或者 - 如果它与 MB/GB/TB 一起使用,它只是“做正确的事”吗?

partition parted
  • 1 个回答
  • 3579 Views
Martin Hope
Issac Young
Asked: 2018-08-27 05:11:23 +0800 CST

parted:无效令牌:交换

  • 5

我正在尝试添加标志swap,parted但令牌无效,为什么?

Model: Kingston DataTraveler 3.0 (scsi)
Disk /dev/sda: 15.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End     Size    Type     File system  Flags
 1      512B   2000MB  2000MB  primary  ext4         boot, lba

(parted) set                                                              
Partition number? 1                                                       
Flag to Invert? swap                                                      
parted: invalid token: swap
parted
  • 2 个回答
  • 2906 Views
Martin Hope
acgbox
Asked: 2018-03-26 09:49:31 +0800 CST

分开创建 .img 准备工作

  • 1

在问题“Parted command line not get the same result”中,答案被选为正确(使用“parted”创建IMG文件系统和分区)是:

# parted MyDrive.img \
    mklabel msdos \
    mkpart primary NTFS 1 1024 \
    set 1 lba on \
    align-check optimal 1 \
    print

Model:  (file)
Disk /dev/shm/MyDrive.img: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
  1      1049kB  1074MB  1073MB  primary  ntfs         lba

fat32/ext4 也一样。但是,当我在 /dev/loop ( sudo losetup loop1 MyDrive.img) 中安装图像时,它不起作用 ( unknown partition)。

所以这个序列是不完整的。

有人可以帮助我完成为 ext4/ntfs/fat32(GPT和MSDOS)创建 .img 的安全性,以便在将其安装在循环中时进行识别(准备工作)

谢谢!

linux parted
  • 1 个回答
  • 1026 Views
Martin Hope
acgbox
Asked: 2018-03-23 14:47:59 +0800 CST

分开的命令行没有得到相同的结果

  • 2

我创建了我的虚拟磁盘(1024MB):

~$ dd if=/dev/zero of=MyDrive.img iflag=fullblock bs=1M count=1024 && sync

情况1:

现在我将使用内部分区配置它以分区/格式化 MyDrive.img :

~$ parted MyDrive.img
(parted) mklabel msdos
(parted) mkpart primary NTFS 1 1024
(parted) align-check optimal 1

结果:

(parted) print
 Model:  (file)
 Disk /home/user/test/MyDrive.img: 1074MB
 Sector size (logical / physical): 512B / 512B
 Table of partitions: msdos
 Disk Flags: 

 Start Number  End     Size    Type    File system  Flags
  1   1049kB  1024MB  1023MB  primary     ntfs       lba

验证分区:

~$ sudo losetup loop1 MyDrive.img
~$ sudo -H gparted /dev/loop1

到目前为止,一切都很好。现在问题...

案例二:

如果我想使用相同的命令从命令行启动“parted”(在终端中;在 parted 之外),我不会得到相同的结果:

  ~$ parted -s MyDrive.img mklabel msdos
  ~$ parted -s MyDrive.img mkpart primary NTFS 1 1024
  ~$ parted -s MyDrive.img align-check optimal 1
  ~$ parted -s MyDrive.img set 1 lba on

出去:

  ~$ parted -s MyDrive.img print
     Model:  (file)
     Disk /home/user/test/MyDrive.img: 1074MB
     Sector size (logical / physical): 512B / 512B
     Table of partitions: msdos
     Disk Flags: 

     Start Number  End     Size    Type    File system  Flags
       1   1049kB  1024MB  1023MB  primary         

问题:缺少 NTFS 和 LBA(ext3、ext4 等也会发生同样的情况)

原因:

   ~$ parted -s MyDrive.img mklabel msdos # Works
   ~$ parted -s MyDrive.img mkpart primary NTFS 1 1024 # Not Work
   ~$ parted -s MyDrive.img align-check optimal 1  # Works
   ~$ parted -s MyDrive.img set 1 lba on  # Not Work

问题:

如何直接从终端(案例2)的命令行使用选项“-s”(--script)正确执行“parted”以获得相同的输出(案例1)?

谢谢

linux parted
  • 1 个回答
  • 1583 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve