Wednesday, May 15, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 5226  / 2 Years ago, fri, february 18, 2022, 6:20:31

I set up a new Ubuntu Partition a few days ago. Yesterday I installed the Kubuntu-Desktop to replace the Unity thing.

Since I installed the new desktop the Linux-Swap partition won't work anymore and not even recognized as Swap. I don't know how that could happen.



Does anybody of you knows how to fix a problem like that? I understand it has something to do with /etc/fstab, but don't really know what to do with it.



The Swap Partition is 4GB and was set up during installation of Ubuntu.



If it helps, here is the result of: cat /etc/fstab



# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda7 during installation
UUID=345e5bbd-d951-4376-8f4b-724be9d0417b / ext4 errors=remount-ro 0 1
# /boot was on /dev/sda5 during installation
UUID=9669db10-3a55-47cd-8c49-e8e4520ca2d3 /boot ext4 defaults 0 2
# /home was on /dev/sda8 during installation
UUID=38b3f3ac-c96b-4f01-8fcf-eac44c6ed28f /home ext4 defaults 0 2
# swap was on /dev/sda6 during installation
#UUID=6ea517a3-a80a-4acb-bea9-4efea2a71acf none swap sw 0 0
/dev/mapper/cryptswap1 none swap sw 0 0


Edit: Since there was a Question regarding: cat /etc/crypttab



cryptswap1 UUID=6ea517a3-a80a-4acb-bea9-4efea2a71acf /dev/urandom swap,cipher=aes-cbc-essiv:sha256

More From » partitioning

 Answers
7

Try to recreate your swap partition as following steps:



Step 1. Format /dev/sda6 to be a valid swap mkswap /dev/sda6



Step 2. Activate the swap by swapon /dev/sda6



Step 3. Additionally modify /etc/fstab to make swap start after every boot. The swap line will probably be already there. You will just need to update UUID received as output of step 1.



For example in your case REMOVE these lines (IF you don't want Encrypted swap partition):



#UUID=6ea517a3-a80a-4acb-bea9-4efea2a71acf none            swap    sw              0       0
/dev/mapper/cryptswap1 none swap sw 0 0


And add this line instead at the end with NEW UUID that you get in step 1:



UUID=0c9f1cb4-a539-4ca4-8eb2-712d0efc3d10 none            swap    sw              0       0


see here and my answer there




IF you want to keep your Encrypted swap partition do the following
steps:



First things first, we need to know where your swap file is located on
your hard drive. dmesg can help here (or you could also check
/etc/fstab)



So in your case you can see the swap is on /dev/sda6. Next thing to
do is ensure the system is fully up to date, turn swap off so we can
work with the partition and install the necessary files. Ensure to
replace /dev/sda6 with the partition you got from dmesg (or
/etc/fstab) in the step above:



sudo apt-get update
sudo apt-get upgrade
sudo swapoff /dev/sda6
sudo apt-get install lvm2 cryptsetup


Next up, load the module and verify its running.



$ sudo modprobe dm-crypt


You should see something like below



$ sudo lsmod | egrep 'aes|dm_crypt'
dm_crypt 12928 0
aes_i586 8124 1
aes_generic 27484 1 aes_i586


Now we clear the partition of existing data by filling it with random
data. This has two purposes, first so that any old unencrypted data is
overwritten and second so that your encrypted data does not stand out
if your drive is analysed. What I mean by this is, if you have 750 meg
of unused swap and only 250 meg used, then 3/4 of your drive will
contain no data at all, just zeros. This makes the encrypted data
stick out like a sore thumb. If you fill the drive with random data,
the encrypted data just ‘blends in’



$ sudo dd if=/dev/urandom of=/dev/sda6 bs=1M


Again, replace /dev/sda6 with the partition you got from dmesg or
fstab. This command will take a while (about 10 mins or so) and
should produce output similar to this:



dd: writing `/dev/sda6': Input/output error
1028+0 records in
1027+0 records out
1077510144 bytes (1.1 GB) copied, 642.306 s, 1.7 MB/s


Then you need to tell crypttab to set up the partition as encrypted
swap, again ensure to change /dev/sda6 to your partition:



sudo echo cryptoswap /dev/sda6 /dev/urandom cipher=aes-cbc-essiv:sha256,size=256,hash=sha256,swap >> /etc/crypttab


Next, edit the /etc/fstab file and search for the line with ‘swap’
in it. Comment that line out by inserting a # character at the
beginning of the line, then insert the following line and save the
file:



/dev/mapper/cryptoswap none swap sw 0 0


That is now your system set up with encrypted swap. Reboot your system
for the changes to be picked up and the encrypted swap to be started.
To ensure that the swap partition is encrypted after you boot you can
check dmesg again, it should specifically mention cryptoswap:



dmesg | grep swap
[ 73.063397] Adding 979924k swap on /dev/mapper/cryptoswap. Priority:-1 extents:1 across:979924k


If you notice a delay during boot time, or see a message such as
‘waiting for swap’ then move the mouse around a bit. It means the
system is low on entropy to generate random data for initialization of
the encryption. It should only take a second or two.



source



[#22732] Saturday, February 19, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
eryeath

Total Points: 122
Total Questions: 121
Total Answers: 112

Location: Saint Helena
Member since Fri, Aug 26, 2022
2 Years ago
eryeath questions
Sat, May 28, 22, 09:50, 2 Years ago
Fri, Sep 9, 22, 13:09, 2 Years ago
Wed, Sep 8, 21, 03:57, 3 Years ago
Fri, Mar 17, 23, 00:13, 1 Year ago
Sat, Apr 16, 22, 06:07, 2 Years ago
;