1

First I fdisk -l check disk usage

enter image description here

Then check swap file, find /dev/dm-1 is my swap path

enter image description here

I know I can increase swap by adding swap file, but I was wondering if I can do it by revising the default path itself, but failed as below

enter image description here

When I wanted to add 4G, says no space, ok then I tried to add 3G, also failed. Can anyone explain? Thanks

fra-san
  • 9,931
  • 2
  • 21
  • 42
Shawn
  • 11
  • 1
  • `dd` is a data copying tool. You can't use it to increase the size of a partition. – Haxiel Oct 03 '20 at 08:17
  • 2
    Welcome on U&L! It would be great if you could copy/paste the text from your terminal instead of [posting images of it](https://unix.meta.stackexchange.com/q/4086/315749). Also, you can only increase the size of a partition if you have some free space on your drives. Showing the complete output of `lsblk -o +FSTYPE,FSSIZE` may allow other users to give you some advice (or, at least, a thorough explanation). – fra-san Oct 03 '20 at 09:20
  • 2
    I guess you were lucky the swap was not in use when you overwrote its content with garbage (the content of `cl-root` is garbage *in the context* of swap). Almost as if you wrote random data directly to RAM. Structures inside `dm-1` now duplicate (at least partially) `cl-root`. Not only `dm-1` will not be recognized as swap; it may be confused with `cl-root` upon the next reboot (depending on how you mount `cl-root`). To use the swap in its current size you need to `swapoff` the device, `mkswap` it (possibly with `--force`), `swapon` it. (contn'd) – Kamil Maciorowski Oct 03 '20 at 10:38
  • (contn'd) To increase the size you need additional steps between `swapoff` and `mkswap`. The information you provided are IMO not enough to reliably tell what exact steps these should be. `/dev/dm-1` is most likely governed by LVM and you need to work with it to increase the size of the device. – Kamil Maciorowski Oct 03 '20 at 10:42
  • @KamilMaciorowski Thanks, so if not `dd`, how about `fallocate` to do the increase or it also used for data copying? – Shawn Oct 04 '20 at 07:56
  • Most likely `dm-1` is not a regular file, `fallocate` wont work. What is the output of `ls -l /dev/dm-1`? – Kamil Maciorowski Oct 04 '20 at 11:55

0 Answers0