Category Archives: Linux

How to Use Your Bash History in the Linux or macOS Terminal

  • Up Arrow or Ctrl+P: Go to the previous command in your history. Press the key multiple times to walk backwards through the commands you’ve used.
  • Down Arrow or Ctrl+N: Go to the next command in your history. Press the key multiple times to walk forwards through the commands you’ve used.
  • Alt+R: Revert any changes to a command you’ve pulled from your history if you’ve edited it on the current line.

Bash also has a special “recall” mode you can use to search for commands you’ve previously run, rather than scrolling through them one by one.

  • Ctrl+R: Recall the last command matching the characters you provide. Press this shortcut and start typing to search your bash history for a command.
  • Ctrl+O: Run the command you found with Ctrl+R.
  • Ctrl+G: Leave the history searching mode without running a command.

Source: How to Use Your Bash History in the Linux or macOS Terminal

Nvidia Drivers on Linux Mint

If drivers fail to load at boot

Your machine boots up with a low-resolution screen, and and after logging in you see an error message to the effect  of “Your system is currently running without video acceleration. You may experience poor performance and high CPU usage“.

There should also be a button to launch the driver manager.

If you’re unable to change things via the driver manager:

From a shell: edit /etc/modules

Make sure the following three lines are there – if not, add them to the bottom of the file:

nvidia
nvidia-drm
nvidia-modeset

Then reboot.

If that doesn’t work, you can see what the system uses with
ubuntu-devices list

You can use ubuntu-devices autoinstall which should do the job.
Reboot when complete.

Or you can install a specific driver version with

apt install nvidia-driver-470 (or what ever version you need). You can use ubuntu-devices list to see available choices. Reboot when complete.

To remove the driver and its associated dependencies, use apt.
Ex.
sudo apt remove nvidia-driver-470
sudo apt autoremove
Then reboot. It should
then use the open-source nouveau driver.

You can install the open-source driver to revert to the open-source driver:

sudo apt install xserver-xorg-video-nouveau
Then reboot

How To Connect And Mount iSCSI Onto Linux Servers

How To Connect And Mount iSCSI Onto Linux Servers

TLDR;

Discovering targets in iSCSI server:

iscsiadm –mode discovery -t sendtargets –portal 192.168.1.141 192.168.1.141:3260,1 iqn.2006-01.com.openfiler:tsn.d625a0d9cb77

login with the iSCSI LUN:

[root@machine1 ~]# iscsiadm --mode node --targetname  iqn.2006-01.com.openfiler:tsn.d625a0d9cb77  --portal 192.168.1.141 --login

Mount the iscsi target:

mount /dev/sdb2 /mnt

Disconnect/remove  target:

umount /mnt

[root@machine1 ~]# iscsiadm –mode node –targetname  iqn.2006-01.com.openfiler:tsn.d625a0d9cb77  –portal 192.168.1.141 –logout

Optionally delete the record from the database:

iscsiadm -m node -o delete -T iqn.2006-01.com.openfiler:tsn.d625a0d9cb77 –portal 192.168.1.141:3260

 

Details:

iscsi Server: 192.168.1.141
Centos Server: 192.168.1.137

The commands bellow should be working in other Linux distro.

First, install some needed packages.

Centos :

yum -y install iscsi-initiator-utils
service iscsid start
service iscsi start

Ubuntu:

sudo apt-get install open-iscsi

Opensuse

# zypper install open-iscsi

Discovering targets in iSCSI server:

 [root@machine1 ~]# iscsiadm --mode discovery -t sendtargets --portal 192.168.1.141
192.168.1.141:3260,1 iqn.2006-01.com.openfiler:tsn.d625a0d9cb77

Trying to login with the iSCSI LUN:

[root@machine1 ~]# iscsiadm --mode node --targetname  iqn.2006-01.com.openfiler:tsn.d625a0d9cb77  --portal 192.168.1.141 --login
 Logging in to [iface: default, target: iqn.2006-01.com.openfiler:tsn.d625a0d9cb77, portal: 192.168.1.141,3260] (multiple)
 Login to [iface: default, target: iqn.2006-01.com.openfiler:tsn.d625a0d9cb77, portal: 192.168.1.141,3260] successful.
 [root@machine1 ~]#

With this command is responsible of the update of  iSCSI targets database for the files located in /var/lib/iscsi/ :

[root@machine1 ~]# cat /var/lib/iscsi/send_targets/192.168.1.141,3260/st_config
 # BEGIN RECORD 6.2.0-873.10.el6
 discovery.startup = manual
 discovery.type = sendtargets
 discovery.sendtargets.address = 192.168.1.141
 discovery.sendtargets.port = 3260
 discovery.sendtargets.auth.authmethod = None
 discovery.sendtargets.timeo.login_timeout = 15
 discovery.sendtargets.use_discoveryd = No
 discovery.sendtargets.discoveryd_poll_inval = 30
 discovery.sendtargets.reopen_max = 5
 discovery.sendtargets.timeo.auth_timeout = 45
 discovery.sendtargets.timeo.active_timeout = 30
 discovery.sendtargets.iscsi.MaxRecvDataSegmentLength = 32768
 # END RECORD
 [root@machine1 ~]#

Now check if the disk add to your machine

[root@machine1 ~]# fdisk  -l
Disk /dev/sda: 17.8 GB, 17791238144 bytes
 255 heads, 63 sectors/track, 2162 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x000a0b90
Device Boot      Start         End      Blocks   Id  System
 /dev/sda1   *           1        1275    10240000   83  Linux
 /dev/sda2            1275        1913     5120000   8e  Linux LVM
 /dev/sda3            1913        2066     1228800   82  Linux swap / Solaris
Disk /dev/mapper/vg_machine1-LogVol01: 209 MB, 209715200 bytes
 255 heads, 63 sectors/track, 25 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000
Disk /dev/mapper/vg_machine1-LogVol00: 2097 MB, 2097152000 bytes
 255 heads, 63 sectors/track, 254 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000
Disk /dev/sdb: 369 MB, 369098752 bytes
 12 heads, 59 sectors/track, 1018 cylinders
 Units = cylinders of 708 * 512 = 362496 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x00000000
[root@machine1 ~]#

Create file system in this disk (for new iscsi disk only)

[root@machine1 ~]# fdisk  /dev/sdb
 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
 Building a new DOS disklabel with disk identifier 0x41c55bb7.
 Changes will remain in memory only, until you decide to write them.
 After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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
 Command action
 e   extended
 p   primary partition (1-4)
 p
 Partition number (1-4): 2
 First cylinder (1-1018, default 1):
 Using default value 1
 Last cylinder, +cylinders or +size{K,M,G} (1-1018, default 1018):
 Using default value 1018
Command (m for help): w
 The partition table has been altered!
Calling ioctl() to re-read partition table.
 Syncing disks.

and

[root@machine1 ~]# mkfs.ext4 /dev/sdb2
 mke2fs 1.41.12 (17-May-2010)
 Filesystem label=
 OS type: Linux
 Block size=1024 (log=0)
 Fragment size=1024 (log=0)
 Stride=0 blocks, Stripe width=0 blocks
 90112 inodes, 360340 blocks
 18017 blocks (5.00%) reserved for the super user
 First data block=1
 Maximum filesystem blocks=67633152
 44 block groups
 8192 blocks per group, 8192 fragments per group
 2048 inodes per group
 Superblock backups stored on blocks:
 8193, 24577, 40961, 57345, 73729, 204801, 221185
Writing inode tables: done
 Creating journal (8192 blocks): done
 Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 37 mounts or
 180 days, whichever comes first.  Use tune2fs -c or -i to override.

Prepare the directory to mount the disk.

[root@machine1 ~]#[root@machine1 ~]# mkdir  /iscsi-openfiler
 [root@machine1 ~]# mount  -t ext4 /dev/sdb2  /iscsi-openfiler/
 [root@machine1 ~]# df -h
 Filesystem            Size  Used Avail Use% Mounted on
 /dev/sda1             9.7G  2.4G  6.9G  26% /
 tmpfs                 751M     0  751M   0% /dev/shm
 /dev/mapper/vg_machine1-LogVol00
 2.0G   35M  1.8G   2% /home
 /dev/mapper/vg_machine1-LogVol01
 194M  5.6M  179M   4% /tmp
 /dev/sdb2             341M   11M  314M   4% /iscsi-openfiler

Please add this to mount the net drive with Linux start.
add this to /etc/fstab.

/dev/sdb2  /iscsi-openfiler   ext4 _netdev,rw 0 0

and

chkconfig  netfs  on
chkconfig  iscsi on

There are three ways to disable or delete an iSCSI target.

First, to disable an iSCSI target:

# iscsiadm --m node -T iqn.2006-01.com.openfiler:tsn.d625a0d9cb77 --portal 192.168.1.141:3260 -u

Second, it is possible to delete the target’s record ID:/p>

# iscsiadm -m node -o delete -T iqn.2006-01.com.openfiler:tsn.d625a0d9cb77 --portal 192.168.1.141:3260

Thirdly, stop the iSCSI service.

Source: How To Connect And Mount iSCSI Onto Linux Servers | Unixmen